:root {
    --primary-color: #2563eb;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 6px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, var(--primary-color), #1d4ed8);
    color: white;
    padding: 24px 32px;
    border-radius: var(--radius-lg);
    margin-bottom: 32px;
    box-shadow: var(--shadow-lg);
}

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

.header h1 {
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stats {
    display: flex;
    gap: 32px;
    background: rgba(255, 255, 255, 0.1);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.last-update {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    opacity: 0.9;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.connection-icon {
    font-size: 12px;
    transition: color 0.3s ease;
}

.connection-icon.connected {
    color: var(--success-color);
}

.connection-icon.disconnected {
    color: var(--danger-color);
}

.main-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
    gap: 24px;
    flex-grow: 1;
    margin-bottom: 32px;
}

.area-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.area-section:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.area-header h2 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.area-stats {
    display: flex;
    gap: 16px;
    font-size: 14px;
    font-weight: 500;
}

.area-normal {
    color: var(--success-color);
    padding: 4px 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--radius-sm);
}

.area-abnormal {
    color: var(--danger-color);
    padding: 4px 12px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-sm);
}

.line-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.line-button {
    position: relative;
    background: var(--background-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    user-select: none;
    outline: none;
}

.line-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.line-button:active {
    transform: translateY(0);
}

.line-button.normal {
    border-color: var(--success-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
}

.line-button.abnormal {
    border-color: var(--danger-color);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
    animation: pulse 2s infinite;
}

.line-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.line-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 20px;
}

.line-button.normal .line-status {
    background: var(--success-color);
    color: white;
}

.line-button.abnormal .line-status {
    background: var(--danger-color);
    color: white;
}

.status-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.line-button.normal .status-indicator {
    background: var(--success-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.line-button.abnormal .status-indicator {
    background: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.hint {
    margin-top: 8px;
    font-size: 13px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 24px;
}
.modal-body p {
    text-align: center;
}

.modal-body p {
    margin-bottom: 16px;
    font-size: 16px;
}

.modal-body .status-indicator {
    position: static;
    width: 20px;
    height: 20px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-normal {
    background: var(--success-color);
    color: white;
}

.btn-normal:hover {
    background: #0da271;
    transform: translateY(-2px);
}

.btn-abnormal {
    background: var(--danger-color);
    color: white;
}

.btn-abnormal:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        flex-direction: column;
        gap: 20px;
        align-items: flex-start;
    }
    
    .stats {
        width: 100%;
        justify-content: space-around;
    }
    
    .line-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}