/* 초기화 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2196F3;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #f44336;
    --secondary: #757575;
    --bg-light: #f5f5f5;
    --bg-white: #ffffff;
    --border: #e0e0e0;
    --text-primary: #212121;
    --text-secondary: #757575;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
}

/* 화면 전환 */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* 로그인 화면 */
#loginScreen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.error-message {
    color: var(--danger);
    font-size: 14px;
    text-align: center;
    display: none;
}

.error-message.show {
    display: block;
}

/* 버튼 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-primary:hover {
    background: #1976D2;
}

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

.btn-secondary:hover {
    background: #616161;
}

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

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

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* 헤더 */
.header {
    background: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-left h1 {
    font-size: 20px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}

/* 사이드바 */
.sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 240px;
    background: white;
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.nav {
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s;
}

.nav-item:hover {
    background: var(--bg-light);
}

.nav-item.active {
    background: #E3F2FD;
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.nav-item span {
    font-size: 20px;
}

/* 메인 콘텐츠 */
.main-content {
    margin-left: 240px;
    margin-top: 64px;
    padding: 24px;
    min-height: calc(100vh - 64px);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

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

.page-header h2 {
    font-size: 24px;
}

.page-actions {
    display: flex;
    gap: 12px;
}

/* 통계 카드 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    gap: 16px;
}

.stat-icon {
    font-size: 40px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border-radius: 12px;
}

.stat-content {
    flex: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary);
}

.stat-change {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 대시보드 섹션 */
.dashboard-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.dashboard-section h3 {
    margin-bottom: 16px;
}

/* 테이블 */
.table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--bg-light);
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
}

.data-table td {
    padding: 16px;
    border-top: 1px solid var(--border);
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: var(--bg-light);
}

/* 검색 */
.search-input {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    width: 300px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* 필터 */
.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

/* 입차 통계 */
.entry-stats {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 24px;
    display: flex;
    gap: 32px;
}

.entry-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.entry-stat .label {
    font-weight: 500;
}

.entry-stat .value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
}

.entry-stat .unit {
    color: var(--text-secondary);
}

/* 센터 그리드 */
.centers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 24px;
}

.center-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

.center-name {
    font-size: 20px;
    font-weight: bold;
}

.center-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.center-status.active {
    background: #E8F5E9;
    color: var(--success);
}

.center-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.center-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
}

.center-stat {
    flex: 1;
    text-align: center;
}

.center-stat-value {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary);
}

.center-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.center-actions {
    display: flex;
    gap: 8px;
}

/* 통계 분석 */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-item {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-number {
    font-size: 36px;
    font-weight: bold;
    color: var(--primary);
}

.stat-unit {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 차트 */
.chart-container {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    height: 400px;
}

/* 설정 */
.settings-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.settings-section h3 {
    margin-bottom: 20px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.setting-input {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    width: 200px;
}

/* 스위치 */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.modal.show,
.modal.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    z-index: 2;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 1.5em;
}

.modal-content .form-group {
    margin-bottom: 20px;
}

.modal-content .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-content .form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.modal-content .form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-content input[type="checkbox"] {
    margin-right: 8px;
}

.modal-close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 3;
}

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

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    justify-content: flex-end;
}

/* 배지 */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #E8F5E9;
    color: var(--success);
}

.badge-warning {
    background: #FFF3E0;
    color: var(--warning);
}

.badge-danger {
    background: #FFEBEE;
    color: var(--danger);
}

.badge-primary {
    background: #E3F2FD;
    color: var(--primary);
}

/* 페이지네이션 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.page-btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 4px;
    cursor: pointer;
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 반응형 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .centers-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .page-actions {
        flex-direction: column;
        width: 100%;
    }

    .search-input {
        width: 100%;
    }
}
