* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6fa;
    color: #2c3e50;
    line-height: 1.4;
    font-size: 13px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px;
}

/* 紧凑的导航和控制栏 */
.compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-wrap: wrap;
    gap: 8px;
}

.nav-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.nav-button {
    padding: 6px 12px;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    transition: background 0.3s;
    border: none;
    cursor: pointer;
}

.nav-button:hover {
    background: #2980b9;
}

.nav-button.active {
    background: #2c3e50;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.control-group {
    display: flex;
    gap: 4px;
    align-items: center;
}

.control-label {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

select, input {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: white;
    font-size: 12px;
    min-width: 80px;
}

.refresh-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.refresh-btn:hover {
    background: #2980b9;
}

/* 可折叠的设备信息栏 */
.collapsible-bar {
    background: white;
    border-radius: 6px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    max-height: 40px;
    transition: max-height 0.3s ease;
}

.collapsible-bar.expanded {
    max-height: 200px;
}

.bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.bar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
}

.toggle-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
}

.device-info-content {
    padding: 10px 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #f1f1f1;
}

.info-label {
    font-weight: 500;
    color: #666;
    font-size: 12px;
}

.info-value {
    font-weight: 600;
    color: #333;
    font-size: 12px;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.status-online {
    background-color: #d4edda;
    color: #155724;
}

.status-offline {
    background-color: #f8d7da;
    color: #721c24;
}

/* 主内容区域 */
.main-content {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0; /* 防止内容溢出 */
}

.right-panel {
    width: 60%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 数据区域样式 */
.data-section {
    background: white;
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-title {
    margin-bottom: 8px;
    color: #2c3e50;
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
}

.data-pairs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 6px;
}

.data-pair {
    display: flex;
    align-items: center;
    padding: 6px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.data-name {
    flex: 1;
    font-weight: 500;
    color: #666;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-value {
    flex: 1;
    font-weight: 600;
    color: #2c3e50;
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unit {
    font-size: 11px;
    color: #7f8c8d;
    margin-left: 1px;
}

/* 图表区域样式 */
.chart-section {
    background: white;
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chart-title {
    margin-bottom: 8px;
    color: #2c3e50;
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
}

.chart-container {
    position: relative;
    flex: 1;
    min-height: 200px;
    width: 100%;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ecf0f1;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #666;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.legend-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* 数值颜色指示 */
.value-normal { color: #27ae60; }
.value-warning { color: #f39c12; }
.value-danger { color: #e74c3c; }

.loading {
    text-align: center;
    padding: 10px;
    color: #7f8c8d;
    font-size: 12px;
}

.last-updated {
    text-align: center;
    color: #7f8c8d;
    font-size: 11px;
    margin-top: 10px;
    padding: 6px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 设备信息网格布局 - 用于设备详细信息 */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 8px 0;
}

.info-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #eee;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 11px;
    color: #666;
    font-weight: 500;
    min-width: 100px;
    text-align: left;
}

.info-value {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    text-align: right;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 设备状态徽章改进 */
.status-info {
    background-color: #3498db;
    color: white;
}

/* 设备选择框样式改进 */
.control-group select {
    min-width: 200px;
    height: 28px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.763-3.762L10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
    padding-right: 30px;
}

.control-group select:hover {
    border-color: #3498db;
}

.control-group select:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* 设备信息区域样式改进 */
#device-name {
    font-weight: 600;
    color: #2c3e50;
    margin: 0 10px;
    font-size: 13px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
    flex-wrap: wrap;
}

/* 设备状态指示器 */
#device-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
}

/* 可折叠栏的动画效果 */
.collapsible-bar.expanded .device-info-content {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 设备信息加载状态 */
.device-info-content .loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    font-style: italic;
}

/* 设备信息详情中的链接样式 */
.device-info-content a {
    color: #3498db;
    text-decoration: none;
    font-size: 11px;
}

.device-info-content a:hover {
    text-decoration: underline;
}

/* 设备数据统计 */
.device-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-label {
    font-size: 10px;
    color: #666;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
}

/* 语言切换按钮 */
.lang-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 60px;
    justify-content: center;
}

.lang-btn:hover {
    background: #5a6268;
}

/* =========================================== */
/* 历史数据页面专用样式 */
/* =========================================== */

.history-container {
    padding: 15px;
    background-color: #f5f6fa;
    min-height: 100vh;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
    padding: 25px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.filter-label::before {
    content: "📊";
    font-size: 12px;
}

.filter-select, .filter-input {
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: #fafafa;
    transition: all 0.3s;
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    background: white;
}

.date-range {
    display: flex;
    gap: 10px;
    align-items: center;
}

.date-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: #fafafa;
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 0 10px;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2980b9, #1c6ea4);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #219653);
    color: white;
    box-shadow: 0 2px 5px rgba(39, 174, 96, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #219653, #1e7e34);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(39, 174, 96, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
    box-shadow: 0 2px 5px rgba(149, 165, 166, 0.3);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #7f8c8d, #6c7b7d);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(149, 165, 166, 0.4);
}

.data-table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

.data-table th {
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    padding: 16px 20px;
    text-align: left;
    font-weight: 700;
    color: #2c3e50;
    border-bottom: 2px solid #dee2e6;
    font-size: 13px;
    white-space: nowrap;
}

.data-table td {
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0f0;
    color: #4a5568;
    font-size: 13px;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: all 0.2s;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
    transform: scale(1.002);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
}

.status-normal {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    box-shadow: 0 2px 4px rgba(39, 174, 96, 0.2);
}

.status-warning {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    color: #856404;
    box-shadow: 0 2px 4px rgba(243, 156, 18, 0.2);
}

.status-danger {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.2);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 25px;
    background: white;
    border-top: 1px solid #eee;
    border-radius: 0 0 8px 8px;
}

.page-btn {
    padding: 10px 20px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #3498db;
    transition: all 0.3s;
}

.page-btn:hover:not(:disabled) {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.page-info {
    font-size: 14px;
    color: #666;
    font-weight: 600;
    background: #f8f9fa;
    padding: 8px 16px;
    border-radius: 20px;
}

.loading {
    text-align: center;
    padding: 60px;
    color: #666;
    background: #fafafa;
}

.loading::after {
    content: "🌀";
    display: block;
    font-size: 40px;
    margin: 20px auto;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-data {
    text-align: center;
    padding: 60px;
    color: #999;
    font-style: italic;
    background: #fafafa;
}

.no-data::before {
    content: "📭";
    display: block;
    font-size: 40px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.export-info {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 14px;
    color: #1565c0;
    border-left: 5px solid #2196f3;
    display: none;
    align-items: center;
    gap: 10px;
}

.export-info::before {
    content: "⏳";
    font-size: 20px;
}

/* 数据详情弹出层 */
.data-detail-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 25px 30px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.close-modal {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 15px;
    border-radius: 4px;
    transition: background 0.3s;
}

.close-modal:hover {
    background: rgba(255,255,255,0.3);
}

.modal-body {
    padding: 30px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.detail-group {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.detail-group h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: #666;
    font-size: 14px;
}

.detail-value {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .history-container {
        padding: 10px;
    }

    .filter-section {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .action-buttons {
        flex-wrap: wrap;
    }

    .btn {
        flex: 1;
        min-width: 150px;
    }

    .data-table {
        min-width: 800px;
    }

    .data-table-container {
        overflow-x: auto;
    }
}

@media (max-width: 768px) {
    .history-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .date-range {
        flex-direction: column;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .pagination {
        flex-direction: column;
        gap: 10px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
        font-size: 12px;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .filter-section {
        padding: 15px;
    }

    .history-header {
        padding: 15px;
    }

    .data-table {
        min-width: 600px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* 确保下拉框在移动端正常显示 */
@media (max-width: 768px) {
    .control-group select {
        min-width: 150px;
        font-size: 12px;
    }

    .controls {
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* 主要监控页面响应式设计 */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .right-panel {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 8px;
    }

    .compact-header {
        flex-direction: column;
        align-items: stretch;
    }

    .controls {
        justify-content: space-between;
        width: 100%;
    }

    .data-pairs-grid {
        grid-template-columns: 1fr;
    }

    .chart-legend {
        grid-template-columns: repeat(2, 1fr);
    }

    .info-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .info-column {
        gap: 4px;
    }

    .info-label, .info-value {
        font-size: 10px;
    }

    .control-group select {
        min-width: 120px;
        font-size: 11px;
    }

    #device-name {
        max-width: 120px;
        font-size: 11px;
    }
}

/* 动画效果 */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.data-updating {
    animation: pulse 1s infinite;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}