/* ========================================
   CSS 변수 정의 (Design System)
   ======================================== */
:root {
    /* === 색상 팔레트 === */
    /* 기본 색상 */
    --primary-color: #6c757d;
    --secondary-color: #495057;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #333;
    --white: #fff;
    
    /* 그레이 스케일 */
    --gray-100: #f5f5f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    
    /* === 간격 시스템 === */
    --spacing-xs: 0.25rem;   /* 4px */
    --spacing-sm: 0.5rem;    /* 8px */
    --spacing-md: 1rem;      /* 16px */
    --spacing-lg: 1.5rem;    /* 24px */
    --spacing-xl: 2rem;      /* 32px */
    --spacing-xxl: 3rem;     /* 48px */
    
    /* === 그림자 시스템 === */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    
    /* === 테두리 반경 === */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    
    /* === 전환 효과 === */
    --transition: all 0.3s ease;
    
    /* === 레이아웃 === */
    --max-width: 1920px;
}

/* ========================================
   기본 스타일 및 리셋
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--gray-100);
    min-height: 100vh;
    color: var(--gray-900);
    line-height: 1.6;
}

/* ========================================
   헤더 컴포넌트
   ======================================== */
.header {
    background: var(--white);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* === 로고 영역 === */
.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo i {
    font-size: 2rem;
    color: var(--gray-600);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* === 네비게이션 메뉴 === */
.nav-menu ul {
    display: flex;
    list-style: none;
    gap: var(--spacing-sm);
}

.nav-menu a {
    text-decoration: none;
    color: var(--gray-600);
    font-weight: 500;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.nav-menu a:hover,
.nav-menu a.active {
    color: var(--gray-900);
    background: var(--gray-100);
}

/* === 사용자 정보 === */
.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.user-name {
    font-weight: 500;
    color: var(--gray-900);
}

.user-info i {
    font-size: 1.5rem;
    color: var(--gray-600);
}

/* ========================================
   메인 레이아웃
   ======================================== */
.main-content {
    max-width: var(--max-width);
    margin: var(--spacing-sm) auto;
    padding: 0 var(--spacing-sm);
}

/* ========================================
   상태 요약 카드 컴포넌트
   ======================================== */
.status-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
}

.status-card {
    background: var(--white);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: var(--transition);
}

.status-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.status-card i {
    font-size: 2.5rem;
    color: var(--gray-600);
}

.status-info h3 {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
}

.status-info .value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--spacing-xs);
}

.status-info .change {
    font-size: 0.8rem;
    color: var(--gray-600);
    font-weight: 500;
}

.status-info .change.positive {
    color: var(--success-color);
}

/* ========================================
   모니터링 섹션
   ======================================== */
.monitoring-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.system-diagram,
.graph-section {
    background: var(--white);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
}

.system-diagram h2,
.graph-section h2 {
    color: var(--gray-900);
    margin-bottom: var(--spacing-lg);
    font-size: 1.3rem;
    font-weight: 600;
}

/* ========================================
   마이크로그리드 시스템 다이어그램
   ======================================== */
.microgrid-diagram {
    background: var(--white);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-sm);
}

.microgrid-diagram h2 {
    color: var(--gray-900);
    margin-bottom: var(--spacing-lg);
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
}

/* === 다이어그램 컨테이너 === */
.diagram-container {
    position: relative;
    min-height: 420px;
    background: var(--light-color);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
    padding: 0.25rem;
    display: grid;
    grid-template-columns: 1fr auto auto auto 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 0.25rem;
    column-gap: 1.5rem;
    row-gap: 0.5rem;
    align-items: center;
    transition: var(--transition);
    max-width: var(--max-width);
    margin: 0 auto;
}

/* ========================================
   PV 패널 섹션
   ======================================== */
.pv-section {
    grid-column: 1;
    grid-row: 1;
    width: 350px;
    justify-self: start;
    z-index: 10;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* === PV 래퍼 === */
.pv-wrapper {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 249, 250, 0.9) 100%);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-lg);
    padding: 1.05rem;
    box-shadow: var(--shadow-md);
    position: relative;
}

.pv-wrapper::before {
    content: 'MLPE';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: var(--white);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

/* === PV 배열 === */
.pv-array {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 0.8rem;
    align-items: center;
    padding: var(--spacing-sm);
}

/* === PV 패널 (MLPE) === */
.pv-panel.mlpe {
    width: 98px;
    height: 126px;
    background: var(--success-color);
    border: 2px solid #1e7e34;
    border-radius: var(--border-radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    padding: 7px 4px;
}

/* PV 패널 상태별 스타일 */
.pv-panel.mlpe.warning {
    background: var(--warning-color);
    border-color: #e0a800;
}

.pv-panel.mlpe.error {
    background: var(--danger-color);
    border-color: #c82333;
}

.pv-panel.mlpe.offline {
    background: var(--gray-600);
    border-color: #545b62;
}

.pv-panel.mlpe:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* === MLPE 라벨 === */
.mlpe-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--white);
    text-align: center;
    line-height: 1;
    z-index: 2;
    position: relative;
    margin-bottom: 4px;
}

/* ========================================
   MLPE 데이터 표시 컴포넌트
   ======================================== */
.mlpe-data {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.mlpe-data-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-sm);
    padding: 4px 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.mlpe-data-label {
    font-size: 0.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.2;
    margin-bottom: 1px;
}

.mlpe-data-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1.2;
    font-family: 'Courier New', monospace;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ========================================
   MLPE 총계 테이블
   ======================================== */
.mlpe-summary-table {
    grid-column: 1;
    grid-row: 2;
    background: var(--white);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    width: 480px;
    justify-self: start;
    z-index: 10;
    position: relative;
}

.mlpe-summary-table h3 {
    color: var(--gray-800);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    text-align: center;
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--gray-200);
}

.mlpe-summary-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.mlpe-summary-table th,
.mlpe-summary-table td {
    padding: var(--spacing-xs) var(--spacing-sm);
    text-align: center;
    border: 1px solid var(--gray-200);
}

.mlpe-summary-table th {
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.65rem;
}

.mlpe-summary-table td {
    color: var(--gray-800);
    font-weight: 500;
    background: var(--white);
}

.mlpe-summary-table td:first-child {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

/* === MLPE 상태별 색상 === */
.mlpe-summary-table .total-status {
    color: var(--success-color);
    font-weight: 600;
}

.mlpe-summary-table .normal-count {
    color: var(--success-color);
    font-weight: 600;
}

.mlpe-summary-table .warning-count {
    color: var(--warning-color);
    font-weight: 600;
}

.mlpe-summary-table .error-count {
    color: var(--danger-color);
    font-weight: 600;
}



/* ========================================
   Battery Bank 총계 테이블
   ======================================== */
.battery-summary-table {
    grid-column: 3;
    grid-row: 2;
    background: var(--white);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    width: 480px;
    justify-self: center;
}

.battery-summary-table h3 {
    color: var(--gray-800);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    text-align: center;
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--gray-200);
}

.battery-summary-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.battery-summary-table th,
.battery-summary-table td {
    padding: var(--spacing-xs) var(--spacing-sm);
    text-align: center;
    border: 1px solid var(--gray-200);
}

.battery-summary-table th {
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.65rem;
}

.battery-summary-table td {
    color: var(--gray-800);
    font-weight: 500;
    background: var(--white);
}

.battery-summary-table td:first-child {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

/* === 배터리 상태별 색상 === */
.battery-summary-table .battery-total-status {
    color: var(--info-color);
    font-weight: 600;
}

.battery-summary-table .battery-normal-count {
    color: var(--success-color);
    font-weight: 600;
}

.battery-summary-table .battery-warning-count {
    color: var(--warning-color);
    font-weight: 600;
}

.battery-summary-table .battery-error-count {
    color: var(--danger-color);
    font-weight: 600;
}

/* ========================================
   공통 테이블 스타일 (참조용)
   - 모든 테이블은 동일한 기본 스타일을 사용
   - border-collapse: collapse, font-size: 0.9rem
   - th: gray-100 배경, td: white 배경
   - padding: var(--spacing-xs) var(--spacing-sm)
   ======================================== */

/* ========================================
   상태 표시 컴포넌트
   ======================================== */
.status-normal {
    background: #d4edda;
    color: #155724;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
}

.status-warning {
    background: #fff3cd;
    color: #856404;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
}

/* ========================================
   시스템 블록 컴포넌트
   ======================================== */

/* === MPPT 블록 === */
.mppt-block {
    grid-column: 2;
    grid-row: 1;
    width: 98px;
    height: 98px;
    background: var(--gray-200);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    z-index: 10;
    position: relative;
    transform: translateX(-50%);
}

/* === 계량기 블록 === */
.meter-block {
    grid-column: 5;
    grid-row: 1;
    width: 280px;
    height: 98px;
    background: var(--white);
    border: 2px solid var(--gray-300);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    justify-self: end;
    z-index: 10;
    position: relative;
    padding: 1.05rem;
    box-shadow: var(--shadow-sm);
    transform: translateX(0%);
}

.meter-block::before {
    content: 'Meter';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: var(--white);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

/* === 블록 라벨 === */
.block-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* === 인버터 블록 === */
.inverter-block {
    grid-column: 4;
    grid-row: 1;
    width: 140px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 249, 250, 0.9) 100%);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    justify-self: end;
    z-index: 10;
    position: relative;
    padding: 10px 6px;
    box-shadow: var(--shadow-md);
    transform: translateX(50%);
}

.inverter-block::before {
    content: 'Inverter';
    position: absolute;
    top: -12px;
    left: 30%;
    background: var(--primary-color);
    color: var(--white);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ========================================
   인버터 데이터 표시 컴포넌트
   ======================================== */
.inverter-data {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.inverter-data-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    padding: 6px 8px;
    border: 1px solid rgba(108, 117, 125, 0.3);
    box-shadow: var(--shadow-sm);
    min-height: 35px;
    justify-content: center;
}

.inverter-data-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--gray-700);
    line-height: 1.2;
    margin-bottom: 2px;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

.inverter-data-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
    font-family: 'Courier New', monospace;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

/* === 인버터 출력전압 표시 (meter 연결선 쪽) === */
.inverter-output-voltage {
    position: absolute;
    top: 35%;
    right: -50%;
    background: var(--success-color);
    color: var(--white);
    padding: 4px 8px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
    min-width: 60px;
    z-index: 15;
}

.inverter-output-label {
    font-size: 0.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.1;
    margin-bottom: 1px;
}

.inverter-output-value {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1.1;
    font-family: 'Courier New', monospace;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* === 인버터 입력전압 표시 (연결선 쪽) === */
.inverter-input-voltage {
    position: absolute;
    bottom: 50%;
    left: -50%;
    background: var(--info-color);
    color: var(--white);
    padding: 4px 8px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
    min-width: 60px;
    z-index: 15;
}

.inverter-input-label {
    font-size: 0.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.1;
    margin-bottom: 1px;
}

.inverter-input-value {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1.1;
    font-family: 'Courier New', monospace;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ========================================
   계량기 내부 표시부
   ======================================== */
.meter-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--spacing-sm);
}

.meter-section:first-child {
    border-right: 1px solid var(--gray-200);
}

.meter-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 0.75rem;
    text-align: center;
    line-height: 1.2;
}

.meter-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--spacing-xs);
    font-family: 'Courier New', monospace;
}

.meter-unit {
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   배터리 뱅크 컴포넌트
   ======================================== */
.battery-bank {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    gap: var(--spacing-sm);
    justify-self: center;
    z-index: 10;
    position: relative;
    transform: translateX(0%);
}

/* === 배터리 래퍼 === */
.battery-wrapper {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 249, 250, 0.9) 100%);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
    position: relative;
    min-width: 320px;
}

.battery-wrapper::before {
    content: 'Battery Bank';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: var(--white);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

/* === 배터리 === */
.battery {
    width: 300px;
    height: 60px;
    background: var(--white);
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    position: relative;
    padding: 4px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

/* ========================================
   배터리 정보 표시 컴포넌트
   ======================================== */
.battery-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
}

.battery-info-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 0.3rem;
}

.battery-info-value {
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Segoe UI', sans-serif;
}

/* 배터리 상태별 색상 */
.battery-info-value.charging {
    color: var(--danger-color);
}

.battery-info-value.discharging {
    color: var(--info-color);
}

.battery-info-value.soc {
    color: var(--success-color);
    font-weight: 700;
}

.battery-info-value.temperature {
    color: var(--gray-700);
}

.battery-status {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--gray-700);
    text-align: center;
    margin-top: 3px;
}

.battery:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ========================================
   발전기 아이콘 컴포넌트
   ======================================== */
.generator-icon {
    position: relative;
    width: 60px;
    height: 40px;
}

.tank {
    position: absolute;
    width: 12px;
    height: 20px;
    background: var(--info-color);
    border-radius: 6px;
}

.tank-1 {
    left: 8px;
    top: 0;
}

.tank-2 {
    right: 8px;
    top: 0;
}

.leaf-symbol {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: var(--success-color);
    border-radius: 50%;
}

.leaf-symbol::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: var(--white);
    border-radius: 50%;
}

/* ========================================
   연결선 컴포넌트
   ======================================== */
.connection-line {
    position: absolute;
    background: var(--primary-color);
    border-radius: 2px;
    z-index: 0;
}

/* ========================================
   풋터 컴포넌트
   ======================================== */
.footer {
    background: var(--dark-color);
    color: var(--white);
    margin-top: var(--spacing-xxl);
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing-sm);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-sm);
}

.footer-section h4 {
    color: var(--white);
    margin-bottom: var(--spacing-sm);
    font-size: 1.1rem;
}

.footer-section p {
    color: #ccc;
    margin-bottom: var(--spacing-sm);
    font-size: 0.9rem;
}

.social-links {
    display: flex;
    gap: var(--spacing-sm);
}

.social-links a {
    color: #ccc;
    font-size: 1.5rem;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: var(--white);
}

.footer-bottom {
    border-top: 1px solid #555;
    padding: var(--spacing-sm);
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

/* ========================================
   반응형 디자인 (Responsive Design)
   ======================================== */

/* === 대형 테블릿 (1200px 이하) === */
@media (max-width: 1200px) {
    .header-content {
        padding: 0.8rem 1.5rem;
    }
    
    .logo h1 {
        font-size: 1.3rem;
    }
    
    .main-content {
        padding: 0 1.5rem;
        margin: 1.5rem auto;
    }
    
    .microgrid-diagram {
        padding: 1.5rem;
    }
    
    .microgrid-diagram h2 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .diagram-container {
        padding: 2rem;
        gap: 2rem;
        max-width: var(--max-width);
    }
    
    .pv-section {
        width: 315px;
        justify-self: center;
    }
    
    .pv-wrapper {
        padding: 1.2rem;
    }
    
    .pv-panel.mlpe {
        width: 60px;
        height: 77px;
        padding: 3px 2px;
    }
    
    .mlpe-label {
        font-size: 0.65rem;
    }
    
    .mlpe-data-label {
        font-size: 0.5rem;
    }
    
    .mlpe-data-value {
        font-size: 0.6rem;
    }
    
    /* MLPE 총계 테이블 반응형 */
    .mlpe-summary-table {
        padding: var(--spacing-sm);
    }
    
    .mlpe-summary-table h3 {
        font-size: 0.8rem;
    }
    
    .mlpe-summary-table table {
        font-size: 0.6rem;
    }
    
    .mlpe-summary-table th,
    .mlpe-summary-table td {
        padding: 2px 4px;
    }
    
    /* Battery Bank 총계 테이블 반응형 */
    .battery-summary-table {
        padding: var(--spacing-sm);
        width: 100%;
        max-width: 400px;
    }
    
    .battery-summary-table h3 {
        font-size: 0.8rem;
    }
    
    .battery-summary-table table {
        font-size: 0.6rem;
    }
    
    .battery-summary-table th,
    .battery-summary-table td {
        padding: 2px 4px;
    }
    
    .mppt-block {
        width: 91px;
        height: 91px;
    }
    
    .inverter-block {
        width: 126px;
        height: 126px;
        padding: 7px 4px;
    }
    
    .inverter-data-item {
        padding: 5px 6px;
        min-height: 32px;
    }
    
    .inverter-data-label {
        font-size: 0.55rem;
    }
    
    .inverter-data-value {
        font-size: 0.8rem;
    }
    
    .inverter-input-voltage {
        bottom: 50%;
        left: -50%;
        min-width: 55px;
        padding: 3px 6px;
    }
    
    .inverter-input-label {
        font-size: 0.45rem;
    }
    
    .inverter-input-value {
        font-size: 0.65rem;
    }
    
    .meter-block {
        width: 245px;
        height: 91px;
        padding: 0.84rem;
    }
    
    .meter-value {
        font-size: 1.2rem;
    }
    
    .meter-section-title {
        font-size: 0.6rem;
    }
    
    .battery-bank {
        transform: translateX(35%) translateY(-30%);
    }
    
    .battery-wrapper {
        padding: 1.5rem;
        gap: 1rem;
    }
    
    .battery {
       width: 300px;
       height: 60px;
       padding: 4px;
    }
    
    .battery-info-label {
        font-size: 0.6rem;
    }
    
    .battery-info-value {
        font-size: 0.75rem;
    }
}

/* === 중간 테블릿 (900px 이하) === */
@media (max-width: 900px) {
    .header-content {
        padding: 0.7rem 1.2rem;
    }
    
    .logo h1 {
        font-size: 1.2rem;
    }
    
    .main-content {
        padding: 0 1.2rem;
        margin: 1.2rem auto;
    }
    
    .microgrid-diagram {
        padding: 1.2rem;
    }
    
    .microgrid-diagram h2 {
        font-size: 1.1rem;
    }
    
    .diagram-container {
        padding: 1.5rem;
        gap: 1.5rem;
        max-width: 1200px;
    }
    
    .pv-section {
        width: 400px;
    }
    
    .pv-wrapper {
        padding: 1rem;
    }
    
    .pv-panel.mlpe {
        width: 120px;
        height: 160px;
        padding: 7px 4px;
    }
    
    .mlpe-label {
        font-size: 0.6rem;
    }
    
    .mlpe-data-label {
        font-size: 0.45rem;
    }
    
    .mlpe-data-value {
        font-size: 0.9rem;
    }
    
    .mppt-block {
        width: 120px;
        height: 120px;
    }
    
    .inverter-block {
        width: 160px;
        height: 160px;
        padding: 8px 5px;
    }
    
    .inverter-data-item {
        padding: 4px 5px;
        min-height: 30px;
    }
    
    .inverter-data-label {
        font-size: 0.5rem;
    }
    
    .inverter-data-value {
        font-size: 0.75rem;
    }
    
    .inverter-input-voltage {
        bottom: 50%;
        left: -50%;
        min-width: 50px;
        padding: 2px 5px;
    }
    
    .inverter-input-label {
        font-size: 0.4rem;
    }
    
    .inverter-input-value {
        font-size: 0.6rem;
    }
    
    .meter-block {
        width: 300px;
        height: 120px;
        padding: 1rem;
    }
    
    .meter-value {
        font-size: 1.1rem;
    }
    
    .meter-section-title {
        font-size: 0.55rem;
    }
    
    .battery-bank {
        transform: translateX(30%) translateY(-30%);
    }
    
    .battery-wrapper {
        padding: 1.2rem;
        gap: 0.8rem;
    }
    
    .battery {
        width: 300px;
        height: 60px;    
        padding: 5px;
    }
    
    .battery-info-label {
        font-size: 0.55rem;
    }
    
    .battery-info-value {
        font-size: 0.7rem;
    }
}

/* === 작은 테블릿 (768px 이하) === */
@media (max-width: 768px) {
    .header-content {
        padding: 0.6rem 1rem;
    }
    
    .logo h1 {
        font-size: 1.1rem;
    }
    
    .main-content {
        padding: 0 1rem;
        margin: 1rem auto;
    }
    
    .microgrid-diagram {
        padding: 1rem;
    }
    
    .microgrid-diagram h2 {
        font-size: 1rem;
    }
    
    .pv-section {
        width: 350px;
    }
    
    .pv-wrapper {
        padding: 0.8rem;
    }
    
    .pv-panel.mlpe {
        width: 110px;
        height: 150px;
        padding: 6px 3px;
    }
    
    .mlpe-label {
        font-size: 0.55rem;
    }
    
    .mlpe-data-label {
        font-size: 0.4rem;
    }
    
    .mlpe-data-value {
        font-size: 0.5rem;
    }
    
    .mppt-block {
        width: 110px;
        height: 110px;
    }
    
    .inverter-block {
        width: 140px;
        height: 140px;
        padding: 6px 4px;
    }
    
    .inverter-data-item {
        padding: 3px 4px;
        min-height: 28px;
    }
    
    .inverter-data-label {
        font-size: 0.45rem;
    }
    
    .inverter-data-value {
        font-size: 0.7rem;
    }
    
    .inverter-input-voltage {
        bottom: 50%;
        left: -50%;
        min-width: 45px;
        padding: 2px 4px;
    }
    
    .inverter-input-label {
        font-size: 0.35rem;
    }
    
    .inverter-input-value {
        font-size: 0.55rem;
    }
    
    .meter-block {
        width: 280px;
        height: 110px;
        padding: 0.8rem;
    }
    
    .meter-value {
        font-size: 1rem;
    }
    
    .meter-section-title {
        font-size: 0.5rem;
    }
    
    .battery-bank {
        transform: translateX(25%) translateY(-30%);
    }
    
    .battery-wrapper {
        padding: 1rem;
        gap: 0.6rem;
    }
    
    .battery {
        width: 300px;
        height: 60px;    
        padding: 4px;
    }
    
    .battery-info-label {
        font-size: 0.5rem;
    }
    
    .battery-info-value {
        font-size: 0.65rem;
    }
}

/* ========================================
   마이크로그리드 시스템 그래프
   ======================================== */
.microgrid-graph {
    background: var(--white);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.microgrid-graph h2 {
    color: var(--gray-900);
    margin-bottom: var(--spacing-lg);
    text-align: center;
    font-size: 1.5rem;
}

/* === 그래프 섹션 컨테이너 (2:8 비율) === */
.graph-section-container {
    display: grid;
    grid-template-columns: 2fr 8fr;
    gap: var(--spacing-lg);
    min-height: 500px;
}

/* === 왼쪽 컨트롤 패널 === */
.graph-control-panel {
    background: var(--gray-100);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-sm);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* === 그래프/테이블 전환 탭 === */
.view-toggle-tabs {
    display: flex;
    flex-direction: row;
    gap: 0;
    background: var(--gray-200);
    border-radius: var(--border-radius-sm);
    padding: 2px;
    border: 1px solid var(--gray-300);
}

.view-toggle-tabs .tab-button {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: transparent;
    color: var(--gray-700);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
    text-align: center;
}

.view-toggle-tabs .tab-button:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.view-toggle-tabs .tab-button.active {
    background: var(--white);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.view-toggle-tabs .tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
    border-radius: 1px;
}

/* === 그래프 범례 (세로 배치) === */
.graph-legend-vertical {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.legend-item-vertical {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--white);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--gray-200);
    cursor: pointer;
    transition: var(--transition);
}

.legend-item-vertical:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.legend-item-vertical.hidden {
    opacity: 0.4;
    text-decoration: line-through;
}

.legend-item-vertical.hidden .legend-color {
    opacity: 0.2;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-label {
    font-size: 0.8rem;
    color: var(--gray-700);
    font-weight: 500;
}

/* === 통계 정보 그리드 (3x2) === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: var(--spacing-sm);
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-sm);
    border: 1px solid var(--gray-200);
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
    font-size: 0.7rem;
    color: var(--gray-600);
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    line-height: 1.2;
}

.stat-card .stat-value {
    font-size: 0.9rem;
    color: var(--gray-900);
    font-weight: 600;
    font-family: 'Courier New', monospace;
    line-height: 1.2;
}

/* === 테이블 선택 메뉴 === */
.table-selector-vertical {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.table-selector-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--white);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--gray-200);
    cursor: pointer;
    transition: var(--transition);
}

.table-selector-item:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    transform: translateX(4px);
}

.table-selector-item.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.table-selector-item.active .table-selector-label {
    color: var(--white);
}

.table-selector-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.table-selector-label {
    font-size: 0.8rem;
    color: var(--gray-700);
    font-weight: 500;
    line-height: 1.2;
}

/* === 테이블 뷰 === */
.table-view {
    background: var(--white);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    margin-top: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.table-section {
    margin-bottom: var(--spacing-xl);
}

.table-section:last-child {
    margin-bottom: 0;
}

.section-title {
    color: var(--gray-800);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--gray-200);
}

.table-section.highlighted {
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

.table-section.highlighted .section-title {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.table-container {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--white);
}

.data-table th {
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
    padding: var(--spacing-sm);
    text-align: center;
    border: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: var(--spacing-sm);
    text-align: center;
    border: 1px solid var(--gray-200);
    color: var(--gray-800);
}

.data-table tbody tr:nth-child(even) {
    background: var(--gray-50);
}

.data-table tbody tr:hover {
    background: var(--gray-100);
    transition: var(--transition);
}

.data-table tbody tr td:first-child {
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-100);
}

/* === 오른쪽 그래프 영역 (8 부분) === */
.graph-main-area {
    background: var(--gray-200);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.graph-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    flex: 1;
}

/* === 그래프 푸터 (오른쪽 영역 하단) === */
.graph-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm);
    background: var(--gray-200);
    border-radius: var(--border-radius-md);
    margin-top: var(--spacing-sm);
}

.graph-legend {
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.7rem;
    color: var(--gray-900);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.legend-item:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.legend-item.hidden {
    opacity: 0.4;
    text-decoration: line-through;
}

.legend-item.hidden .legend-color {
    opacity: 0.2;
}



.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.mlpe-color {
    background: #4CAF50;
}

.battery-charge-color {
    background: #FF0000; /* 빨강 */
}

.battery-discharge-color {
    background: #0000FF; /* 파랑 */
}

.battery-soc-color {
    background: #FF69B4; /* 핑크 */
}

.inverter-color {
    background: #9C27B0;
}

.instant-power-color {
    background: #FF9800; /* 주황색 */
}

.cumulative-power-color {
    background: #795548; /* 갈색 */
}

.graph-time {
    font-size: 0.5rem;
    color: var(--gray-900);
    font-weight: 500;
}

/* === 그래프 차트 영역 === */
.graph-chart {
    background: var(--gray-200);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    height: 400px;
    flex: 1;
    min-height: 400px;
}

.chart-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

/* === 그래프 통계 === */
.graph-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--gray-200);
    border-radius: var(--border-radius-md);
    margin-top: var(--spacing-sm);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--spacing-sm);
    background: var(--white);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--gray-200);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-bottom: var(--spacing-xs);
}

.stat-value {
    font-size: 1.2rem;
    color: var(--gray-900);
    font-weight: 600;
}

/* === 모바일 반응형 (768px 이하) === */
@media (max-width: 768px) {
    .microgrid-graph {
        padding: var(--spacing-sm);
    }
    
    /* 모바일에서는 세로 배치로 변경 */
    .graph-section-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        gap: var(--spacing-md);
    }
    
    .graph-control-panel {
        order: 2;
        padding: var(--spacing-md);
    }
    
    .graph-main-area {
        order: 1;
    }
    
    .view-toggle-tabs {
        flex-direction: row;
        gap: 0;
    }
    
    .view-toggle-tabs .tab-button {
        flex: 1;
        text-align: center;
    }
    
    .graph-legend-vertical {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .legend-item-vertical {
        min-width: 120px;
    }
    
    .graph-footer {
        flex-direction: column;
        gap: var(--spacing-sm);
        align-items: stretch;
    }
    
    .graph-legend {
        justify-content: center;
        gap: var(--spacing-sm);
    }
    
    .graph-chart {
        height: 300px;
        flex-direction: column;
    }
    
    .chart-y-axis {
        width: 100%;
        height: 40px;
        flex-direction: row;
        margin-right: 0;
        margin-bottom: var(--spacing-sm);
    }
    
    .y-label {
        writing-mode: horizontal-tb;
    }
    
    .y-scale {
        flex-direction: row;
        width: 100%;
        height: auto;
    }
    
    .chart-main {
        flex: 1;
    }
    
    .chart-x-axis {
        width: 100%;
        height: 40px;
        flex-direction: row;
        margin-left: 0;
        margin-top: var(--spacing-sm);
    }
    
    .x-scale {
        flex-direction: row;
        width: 100%;
        height: auto;
    }
    
    .graph-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}
