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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background: linear-gradient(135deg, #E8F5E9 0%, #FFF8E1 50%, #DCEDC8 100%);
}

/* 헤더 */
.header {
    background: linear-gradient(135deg, #2E7D32, #1B5E20);
    color: white;
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(46, 125, 50, 0.3);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-img {
    height: 44px;
    background: white;
    border-radius: 8px;
    padding: 4px;
}

.logo-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.page-name {
    font-size: 0.8rem;
    opacity: 0.85;
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-update {
    font-size: 0.8rem;
    opacity: 0.9;
}

.db-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 6px 12px;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
}

.db-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #BDBDBD;
}

.db-indicator.connected {
    background: #81C784;
    box-shadow: 0 0 8px #81C784;
}

.db-indicator.disconnected {
    background: #E53935;
    box-shadow: 0 0 8px #E53935;
}

.btn-data, .btn-refresh {
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    color: white;
}

.btn-data {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-data:hover {
    background: rgba(255,255,255,0.3);
}

.btn-refresh {
    background: #F5A623;
    box-shadow: 0 2px 8px rgba(245, 166, 35, 0.3);
}

.btn-refresh:hover {
    background: #E65100;
}

.btn-refresh.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* 컨테이너 */
.container {
    height: calc(100vh - 64px);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

#errorArea:empty {
    display: none;
}

.error-message {
    background: rgba(229, 57, 53, 0.1);
    color: #E53935;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(229, 57, 53, 0.2);
    margin-bottom: 10px;
}

/* 상태 카드 */
.status-cards {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    flex-shrink: 0;
}

.status-card {
    background: white;
    border-radius: 12px;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    border-top: 4px solid #4CAF50;
}

.status-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.status-card.connected {
    border-top-color: #4CAF50;
}

.status-card.disconnected {
    border-top-color: #E53935;
}

.card-icon {
    font-size: 2.2rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #E8F5E9, #FFF8E1);
    border-radius: 14px;
}

.card-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #424242;
    margin-top: 4px;
}

.card-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1B5E20;
}

.unit {
    font-size: 0.9rem;
    color: #757575;
    font-weight: 500;
    margin-left: 2px;
}

/* 차트 그리드 - 반응형 개선 */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 14px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    min-height: 0;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1B5E20;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.chart-container {
    flex: 1;
    position: relative;
    min-height: 0;
    width: 100%;
    height: 100%;
}

.chart-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* 모달 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #2E7D32, #1B5E20);
    border-radius: 16px 16px 0 0;
    color: white;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(255,255,255,0.3);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px;
    background: #F5F5F5;
    border-radius: 10px;
}

.search-box label {
    font-weight: 600;
    color: #424242;
    white-space: nowrap;
}

.date-input {
    padding: 10px 14px;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.date-input:focus {
    border-color: #4CAF50;
}

.btn-search {
    padding: 10px 20px;
    background: #2E7D32;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-search:hover {
    background: #1B5E20;
}

.search-result {
    font-size: 0.85rem;
    color: #757575;
    margin-left: auto;
}

.table-wrapper {
    max-height: 55vh;
    overflow-y: auto;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid #EEEEEE;
}

.data-table th {
    background: #F5F5F5;
    font-weight: 600;
    color: #1B5E20;
    position: sticky;
    top: 0;
}

.data-table tbody tr:hover {
    background: #F1F8E9;
}

/* 로딩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #EEEEEE;
    border-top-color: #2E7D32;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 반응형 */
@media (max-width: 1200px) {
    .status-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    html, body {
        overflow: auto;
    }
    
    .container {
        height: auto;
        min-height: calc(100vh - 64px);
    }
    
    .header {
        flex-direction: column;
        gap: 10px;
    }
    
    .header-right {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .status-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    
    .chart-card {
        height: 280px;
    }
    
    .chart-container {
        height: calc(100% - 30px);
    }
}
