/* ─── 기본 리셋 & 변수 ─── */
:root {
  --primary: #1e3a5f;
  --primary-light: #2563a8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-w: 220px;
  --header-h: 56px;
  --bg: #f0f4f8;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --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);
  --radius: 8px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Pretendard', 'Noto Sans KR', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ─── 로그인 ─── */
.login-overlay { position: fixed; inset: 0; background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.login-box { background: #fff; border-radius: 16px; padding: 48px 40px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo i { font-size: 48px; color: var(--primary-light); }
.login-logo h1 { font-size: 28px; font-weight: 700; color: var(--primary); margin-top: 8px; }
.login-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.login-notice { text-align: center; margin-top: 16px; color: var(--text-muted); font-size: 12px; }

/* ─── 레이아웃 ─── */
#app { display: flex; height: 100vh; overflow: hidden; }
#sidebar { width: var(--sidebar-w); background: var(--primary); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; transition: width .2s; }
#mainContent { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#pageHeader { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 0 24px; height: var(--header-h); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; box-shadow: var(--shadow); }
#pageTitle { font-size: 18px; font-weight: 600; color: var(--primary); }
#pageBody { flex: 1; overflow-y: auto; padding: 24px; }

/* ─── 사이드바 ─── */
.sidebar-header { padding: 20px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-header i { font-size: 24px; color: #93c5fd; }
.sidebar-title { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.nav-menu { list-style: none; padding: 8px 0; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; cursor: pointer; transition: background .15s; border-left: 3px solid transparent; font-size: 13.5px; }
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: rgba(59,130,246,.25); border-left-color: #60a5fa; color: #93c5fd; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 8px; }
.user-info { flex: 1; display: flex; align-items: center; gap: 8px; overflow: hidden; }
.user-info i { font-size: 28px; color: #93c5fd; flex-shrink: 0; }
.user-info div { overflow: hidden; }
.user-info span { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info small { font-size: 11px; color: #93c5fd; }
.btn-icon { background: none; border: none; color: rgba(255,255,255,.7); font-size: 16px; padding: 6px; border-radius: 6px; transition: all .15s; }
.btn-icon:hover { color: #fff; background: rgba(255,255,255,.15); }

/* ─── KPI 카드 ─── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; }
.kpi-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.kpi-icon.blue   { background: #dbeafe; color: #2563eb; }
.kpi-icon.green  { background: #d1fae5; color: #059669; }
.kpi-icon.orange { background: #ffedd5; color: #ea580c; }
.kpi-icon.purple { background: #ede9fe; color: #7c3aed; }
.kpi-icon.red    { background: #fee2e2; color: #dc2626; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-delta { font-size: 11px; margin-top: 4px; }
.kpi-delta.up   { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* ─── 카드 ─── */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 16px; display: flex; align-items: center; gap: 6px; }
.card-title i { color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* ─── 테이블 ─── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; }
.data-table thead th { background: #f8fafc; padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ─── 배지 ─── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ─── 버튼 ─── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; transition: all .15s; cursor: pointer; border: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ─── 폼 ─── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; transition: border-color .15s; background: #fff; }
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ─── 검색바 ─── */
.search-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search-input { position: relative; }
.search-input input { padding-left: 32px; width: 240px; }
.search-input i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }

/* ─── 페이지네이션 ─── */
.pagination { display: flex; align-items: center; gap: 4px; justify-content: center; margin-top: 16px; }
.page-btn { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; transition: all .15s; }
.page-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── 탭 ─── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; cursor: pointer; }
.tab-btn:hover { color: var(--accent); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ─── 임직원 프로필 ─── */
.emp-profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; padding: 20px; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); }
.emp-avatar { width: 80px; height: 80px; border-radius: 50%; background: #dbeafe; display: flex; align-items: center; justify-content: center; font-size: 36px; color: var(--accent); flex-shrink: 0; overflow: hidden; }
.emp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.emp-info h2 { font-size: 22px; font-weight: 700; }
.emp-info .emp-meta { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ─── 조직도 ─── */
.org-tree { overflow: auto; padding: 20px; }
.org-node { display: inline-flex; flex-direction: column; align-items: center; }
.org-card { background: var(--card-bg); border: 2px solid var(--border); border-radius: 10px; padding: 12px 16px; min-width: 130px; text-align: center; cursor: pointer; transition: all .15s; box-shadow: var(--shadow); }
.org-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.org-card.root { border-color: var(--primary); background: var(--primary); color: #fff; }
.org-card .dept-name { font-weight: 600; font-size: 13px; }
.org-card .dept-manager { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.org-card.root .dept-manager { color: #93c5fd; }
.org-card .dept-count { font-size: 11px; color: var(--accent); margin-top: 4px; font-weight: 600; }
.org-children { display: flex; gap: 16px; position: relative; padding-top: 20px; }
.org-children::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 2px; height: 20px; background: var(--border); }
.org-connector { position: relative; }
.org-connector::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 100%; height: 2px; background: var(--border); }

/* ─── 차트 컨테이너 ─── */
.chart-container { position: relative; }

/* ─── 타임라인 ─── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent); }
.timeline-date { font-size: 11px; color: var(--text-muted); }
.timeline-content { background: #f8fafc; border-radius: 6px; padding: 10px 12px; margin-top: 4px; font-size: 13px; }

/* ─── 모달 ─── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box.modal-lg { max-width: 860px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* ─── 토스트 ─── */
.toast { position: fixed; bottom: 24px; right: 24px; background: #1e293b; color: #fff; padding: 12px 20px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-md); z-index: 9999; animation: slideUp .2s ease; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── 에러 메시지 ─── */
.error-msg { background: #fee2e2; color: #991b1b; padding: 8px 12px; border-radius: 6px; font-size: 12px; margin-bottom: 12px; }

/* ─── 빈 상태 ─── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ─── 반응형 ─── */
@media (max-width: 768px) {
  #sidebar { width: 60px; }
  .sidebar-title, .nav-item span, .user-info div { display: none; }
  .sidebar-header { justify-content: center; padding: 16px 8px; }
  .nav-item { justify-content: center; padding: 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ─── 스크롤바 ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── 유틸리티 ─── */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.cert-tag { display: inline-flex; align-items: center; gap: 4px; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; border-radius: 6px; padding: 4px 10px; font-size: 12px; margin: 3px; }
.cert-tag i { font-size: 11px; }
