/* GS파워 원격검침 설치관리 시스템 v3.0 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-500: #64748b;
  --gray-700: #374151;
  --gray-900: #111827;
  --sidebar-w: 220px;
  --sidebar-w-sm: 56px;
  --header-h: 52px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body { font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif; font-size: 14px; color: var(--gray-700); background: var(--gray-50); overflow-x: hidden; }

/* ===== 로그인 ===== */
#login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--primary); margin: 8px 0 4px; }
.login-logo p { font-size: 13px; color: var(--gray-500); }

/* ===== 레이아웃 ===== */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
  transition: width .25s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-w-sm); }
.sidebar.collapsed .sidebar-logo span,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-user div,
.sidebar.collapsed .sidebar-user button { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-item i { margin: 0; font-size: 18px; }

.sidebar-logo { padding: 18px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.15); }
.sidebar-logo i { color: #93c5fd; font-size: 20px; flex-shrink: 0; }
.sidebar-logo span { color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: rgba(255,255,255,.75);
  text-decoration: none; font-size: 13px; font-weight: 500;
  transition: all .15s; white-space: nowrap; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.18); color: #fff; border-right: 3px solid #93c5fd; }
.nav-item i { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }

.sidebar-user { padding: 14px 14px 18px; border-top: 1px solid rgba(255,255,255,.15); }

.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left .25s ease; }
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-w-sm); }

.page-header {
  height: var(--header-h); display: flex; align-items: center;
  padding: 0 20px; background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.page-header h2 { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.page-body { padding: 20px; flex: 1; }

/* ===== KPI 카드 ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.kpi-card { background: #fff; border-radius: var(--radius); padding: 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.kpi-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.kpi-label { font-size: 11px; color: var(--gray-500); margin-bottom: 3px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--gray-900); line-height: 1; }

/* ===== 카드 ===== */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 14px; font-weight: 600; color: var(--gray-900); display: flex; align-items: center; gap: 8px; }
.card-header h3 i { color: var(--primary); }
.card-body { padding: 16px; }

/* ===== 그리드 ===== */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2col { grid-template-columns: 1fr; } }

/* ===== 테이블 ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { background: #f8fafc; color: var(--gray-500); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }
.table td.empty-state, .table td.loading { text-align: center; color: var(--gray-500); padding: 32px; font-size: 13px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-500); }
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; opacity: .4; }
.loading { text-align: center; padding: 40px; color: var(--gray-500); }

/* ===== 툴바 ===== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== 폼 ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }
.form-input, .form-select, textarea.form-input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--gray-300); border-radius: 6px;
  font-size: 13px; color: var(--gray-700);
  background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.form-input:disabled { background: var(--gray-100); color: var(--gray-500); cursor: not-allowed; }
textarea.form-input { resize: vertical; min-height: 64px; font-family: inherit; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.required { color: var(--danger); margin-left: 2px; }

/* ===== 버튼 ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: all .15s; white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-200); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fee2e2; }

/* ===== 검색박스 ===== */
.search-box { display: flex; align-items: center; gap: 6px; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: 6px; padding: 6px 10px; }
.search-box i { color: var(--gray-500); font-size: 13px; }
.search-box input { border: none; background: transparent; outline: none; font-size: 13px; color: var(--gray-700); min-width: 180px; }

/* ===== 상태 배지 ===== */
.status-badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.st-미착수        { background: #f1f5f9; color: #64748b; }
.st-설치보고수신    { background: #eff6ff; color: #1d4ed8; }
.st-설치완료       { background: #ecfdf5; color: #059669; }
.st-검침성공       { background: #f0fdf4; color: #16a34a; }
.st-검침실패       { background: #fef2f2; color: #dc2626; }
.st-현장보류       { background: #fffbeb; color: #b45309; }
.st-재방문         { background: #fff7ed; color: #c2410c; }
.st-장애접수       { background: #fef2f2; color: #b91c1c; }
.st-NMS등록완료    { background: #f0f9ff; color: #0369a1; }

/* ===== 사업소 배지 ===== */
.office-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.office-anyang  { background: #eff6ff; color: #1d4ed8; }
.office-bucheon { background: #fdf4ff; color: #7e22ce; }

/* ===== 기타 배지 ===== */
.model-badge { display: inline-block; background: #1e40af; color: #fff; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.type-badge  { display: inline-block; background: var(--gray-100); color: var(--gray-700); padding: 2px 7px; border-radius: 4px; font-size: 11px; }
.badge-count { display: inline-block; background: #ede9fe; color: #6d28d9; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-master { display: inline-block; background: #1e40af; color: #fff; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.badge-slave  { display: inline-block; background: #e2e8f0; color: #475569; padding: 2px 7px; border-radius: 4px; font-size: 11px; }

/* ===== 통계 행 ===== */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--gray-500); margin: 6px 0; }
.stat-item strong { color: var(--primary); }

/* ===== 페이지네이션 ===== */
.pager { margin-top: 12px; }
.pager-inner { display: flex; align-items: center; gap: 4px; justify-content: center; flex-wrap: wrap; }
.pager-btn { width: 32px; height: 32px; border: 1px solid var(--gray-200); background: #fff; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--gray-700); display: flex; align-items: center; justify-content: center; transition: all .15s; }
.pager-btn:hover:not(:disabled) { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }
.pager-info { margin-left: 8px; font-size: 12px; color: var(--gray-500); }

/* ===== 탭 ===== */
.detail-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-200); margin-bottom: 16px; }
.tab-btn { padding: 8px 16px; border: none; background: transparent; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--gray-500); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; display: flex; align-items: center; gap: 6px; }
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ===== 상세 테이블 ===== */
.detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail-table th { background: var(--gray-50); color: var(--gray-500); font-weight: 600; padding: 9px 12px; border: 1px solid var(--gray-200); width: 18%; white-space: nowrap; font-size: 12px; }
.detail-table td { padding: 9px 12px; border: 1px solid var(--gray-200); vertical-align: middle; }

/* ===== 모달 ===== */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  display: flex; flex-direction: column;
  max-height: 90vh;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--gray-500); font-size: 18px; padding: 4px; border-radius: 4px; transition: all .15s; }
.modal-close:hover { color: var(--danger); background: #fef2f2; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* ===== 토스트 ===== */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  min-width: 240px; max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  pointer-events: all;
  animation: toastIn .25s ease;
  transition: opacity .3s ease, transform .3s ease;
}
.toast.hide { opacity: 0; transform: translateX(20px); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast.success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.toast.error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.toast.warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.toast.info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.toast i { font-size: 16px; flex-shrink: 0; }

/* ===== 코드 ===== */
code { font-family: 'Consolas', 'Monaco', monospace; background: var(--gray-100); padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* ===== 반응형 ===== */
@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-w-sm); }
  .sidebar .sidebar-logo span, .sidebar .nav-item span, .sidebar .sidebar-user div, .sidebar .sidebar-user button { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 12px; }
  .sidebar .nav-item i { margin: 0; font-size: 18px; }
  .main-content { margin-left: var(--sidebar-w-sm); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2col { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { justify-content: flex-start; }
}

/* ===== 스크롤바 ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
