:root {
  --primary: #1a56db;
  --primary-dark: #1e429f;
  --secondary: #6b7280;
  --success: #057a55;
  --danger: #c81e1e;
  --warning: #9f580a;
  --bg: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans KR', -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── 레이아웃 ── */
#app { display: flex; height: 100vh; overflow: hidden; }
#sidebar {
  width: var(--sidebar-width); background: #1e2a3b; color: #c9d4e0;
  display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
}
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px; display: flex; align-items: center;
  justify-content: space-between; flex-shrink: 0;
}
#content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── 사이드바 ── */
.sidebar-logo {
  padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo-img { display: block; height: 38px; width: auto; margin-bottom: 10px; }
.sidebar-logo-text { font-size: 14px; font-weight: 700; color: #fff; line-height: 1.3; }

.user-card {
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.user-info .name { font-size: 13px; font-weight: 600; color: #fff; }
.user-info .dept { font-size: 11px; color: #8a9bb0; margin-top: 1px; }

.nav-section { padding: 12px 0; }
.nav-label { font-size: 10px; font-weight: 700; color: #5a6a7a; text-transform: uppercase; letter-spacing: .08em; padding: 0 16px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  cursor: pointer; border-left: 3px solid transparent; transition: all .15s;
  font-size: 13px; color: #c9d4e0; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(26,86,219,.25); border-left-color: var(--primary); color: #fff; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; background: #e02424; color: #fff;
  font-size: 11px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
/* ── 드롭다운 메뉴 그룹 ── */
.nav-group { justify-content: space-between; }
.nav-group .nav-caret { margin-left: auto; font-size: 11px; color: #8a99a8; transition: transform .2s; }
.nav-group.open .nav-caret { transform: rotate(180deg); }
.nav-sub { display: none; overflow: hidden; background: rgba(0,0,0,.18); }
.nav-sub.open { display: block; }
.nav-subitem { padding: 7px 16px 7px 44px; font-size: 12.5px; color: #aebccb; }
.nav-subitem.active { background: rgba(26,86,219,.25); border-left-color: var(--primary); color: #fff; }

/* ── 헤더 ── */
.header-title { font-size: 16px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #046c4e; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9b1c1c; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── 카드 ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── 통계 카드 ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; display: flex; align-items: center; gap: 14px;
}
.stat-icon { font-size: 28px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

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

/* ── 배지 ── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-pending { background: #fff8e6; color: #92400e; border: 1px solid #fcd34d; }
.badge-approved { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-rejected { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-recalled { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }
.badge-waiting { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }
.badge-type { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── 폼 ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-label .required { color: #e02424; margin-left: 2px; }
.form-control {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; background: var(--surface);
  transition: border-color .15s; outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,86,219,.1); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── 결재선 설정 ── */
.approval-line { display: flex; flex-direction: column; gap: 8px; }
.approval-step {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px;
}
.step-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.step-info { flex: 1; }
.step-info select { width: 100%; }
.step-arrow { color: var(--text-muted); font-size: 18px; }
.btn-remove-step { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 18px; padding: 0; }

/* ── 문서 상세 ── */
.doc-header {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 20px; margin-bottom: 16px;
}
.doc-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-muted); }
.doc-meta span { display: flex; align-items: center; gap: 4px; }

.approval-timeline { display: flex; flex-direction: row; align-items: flex-start; gap: 0; overflow-x: auto; padding: 6px 0 2px; }
.timeline-step {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  position: relative; flex: 1 0 auto; min-width: 110px; padding: 0 6px;
}
.timeline-step:not(:last-child) .timeline-line {
  position: absolute; left: 50%; top: 18px; width: 100%; height: 2px; background: var(--border); z-index: 0;
}
.timeline-icon {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; z-index: 1; border: 2px solid var(--border); background: var(--surface);
}
.timeline-icon.approved { border-color: var(--success); background: #ecfdf5; color: var(--success); }
.timeline-icon.rejected { border-color: var(--danger); background: #fef2f2; color: var(--danger); }
.timeline-icon.pending { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.timeline-icon.waiting { border-color: var(--border); background: var(--bg); color: var(--secondary); }
.timeline-body { padding-top: 8px; width: 100%; }
.timeline-header { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 2px; }
.timeline-name { font-weight: 600; font-size: 13px; }
.timeline-date { font-size: 11px; color: var(--text-muted); }
.timeline-comment { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-style: italic; word-break: break-word; }

/* ── 검색 ── */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar .form-control { flex: 1; min-width: 200px; }

/* ── 모달 ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: 10px; width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--secondary); padding: 0; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── 알림 ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e2a3b; color: #fff; padding: 12px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,.2);
  animation: slideIn .25s ease; max-width: 320px;
}
.toast.success { border-left: 4px solid #0e9f6e; }
.toast.error { border-left: 4px solid #e02424; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── 빈 상태 ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── 로그인 ── */
#login-screen {
  min-height: 100vh; display: flex; align-items: stretch; justify-content: stretch;
}
.login-bg {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #f5f6f8; padding: 24px;
  background-image: radial-gradient(circle at 70% 20%, rgba(58,170,53,.08) 0%, transparent 50%),
                    radial-gradient(circle at 20% 80%, rgba(26,86,219,.06) 0%, transparent 50%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 6px rgba(0,0,0,.04), 0 20px 48px rgba(0,0,0,.10);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-logo {
  margin-bottom: 20px;
}
.login-title {
  font-size: 15px;
  font-weight: 600;
  color: #374151;
  letter-spacing: 0.04em;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e5e7eb;
  width: 100%;
  text-align: center;
}
.login-card .form-group { width: 100%; }
.login-card .form-label { font-size: 13px; font-weight: 600; color: #374151; }
.login-card .form-control {
  height: 46px; font-size: 14px; border-radius: 8px;
  border: 1.5px solid #e5e7eb; background: #fafafa;
}
.login-card .form-control:focus {
  border-color: #3aaa35; background: #fff;
  box-shadow: 0 0 0 3px rgba(58,170,53,.12);
}
.btn-login {
  width: 100%; height: 48px; border: none; border-radius: 8px;
  background: #3aaa35; color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all .15s; margin-top: 4px; letter-spacing: 0.04em;
  display: flex; align-items: center; justify-content: center;
}
.btn-login:hover { background: #2e8a2a; }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }

/* ── Quill 에디터 ── */
.quill-wrap { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.quill-wrap .ql-toolbar { border: none; border-bottom: 1px solid var(--border); background: var(--bg); }
.quill-wrap .ql-container { border: none; font-family: 'Noto Sans KR', sans-serif; font-size: 14px; min-height: 180px; }
.quill-wrap .ql-editor { min-height: 180px; }
.quill-wrap .ql-editor img { max-width: 100%; border-radius: 4px; margin: 4px 0; }

/* ── 첨부파일 ── */
.attach-zone {
  border: 2px dashed var(--border); border-radius: 6px; padding: 16px;
  text-align: center; cursor: pointer; transition: all .15s; background: var(--bg);
}
.attach-zone:hover, .attach-zone.drag-over { border-color: var(--primary); background: #eff6ff; }
.attach-zone p { font-size: 13px; color: var(--text-muted); margin: 0; }
.attach-zone .attach-icon { font-size: 28px; margin-bottom: 6px; }

.attach-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.attach-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.attach-item .file-icon { font-size: 20px; flex-shrink: 0; }
.attach-item .file-info { flex: 1; min-width: 0; }
.attach-item .file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-item .file-size { font-size: 11px; color: var(--text-muted); }
.attach-item .file-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 0; flex-shrink: 0; }
.attach-item .file-remove:hover { color: var(--danger); }
.attach-item .file-dl { font-size: 12px; color: var(--primary); text-decoration: none; flex-shrink: 0; }
.attach-item .file-dl:hover { text-decoration: underline; }

.upload-progress { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.upload-progress-bar { height: 100%; background: var(--primary); transition: width .3s; }

/* ── 문서함 필터 바 ── */
.docbox-filter {
  padding: 14px 16px; border-bottom: 1px solid var(--border); background: #fafafa;
  display: flex; flex-wrap: wrap; gap: 12px 44px; align-items: flex-start;
}
.docbox-filter .fb-col { display: flex; flex-direction: column; gap: 12px; }
.docbox-filter .fb-left { flex: 0 0 auto; }
.docbox-filter .fb-right { flex: 1 1 300px; min-width: 280px; }
.docbox-filter .fb-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.docbox-filter .fb-label { flex: 0 0 56px; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.docbox-filter .fb-controls { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.docbox-filter .fb-date { width: 150px; }
.docbox-filter .fb-doctype { width: 100%; max-width: 320px; }
.docbox-filter .fb-field { flex: 0 0 110px; }
.docbox-filter .fb-keyword { flex: 1; min-width: 140px; }
.docbox-filter .fb-tilde { color: var(--text-muted); }

/* ── 햄버거 버튼 / 모바일 사이드바 ── */
.hamburger-btn {
  display: none; background: none; border: none; font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--text); padding: 4px 10px 4px 0; margin-right: 2px;
}
#sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90;
}

/* ── 반응형 ── */
@media (max-width: 768px) {
  .hamburger-btn { display: block; }
  /* 사이드바를 화면 밖에서 슬라이드되는 서랍으로 전환 */
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 95;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 2px 0 16px rgba(0,0,0,.3);
  }
  #app.sidebar-open #sidebar { transform: translateX(0); }
  #app.sidebar-open #sidebar-backdrop { display: block; }

  #header { padding: 0 14px; }
  #content { padding: 16px; }
  .header-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

  /* 문서함 필터: 세로 스택 (상신일 → 기안양식 → 검색 → 버튼) */
  .docbox-filter { flex-direction: column; align-items: stretch; gap: 12px; }
  .docbox-filter .fb-col { width: 100%; }
  .docbox-filter .fb-label { flex: 0 0 56px; }
  .docbox-filter .fb-doctype { width: auto; max-width: none; flex: 1; }
  .docbox-filter .fb-date { width: auto; flex: 1; min-width: 0; }
  .docbox-filter .fb-keyword { flex: 1; min-width: 0; }
  .docbox-filter .fb-btn-line .btn { flex: 1; justify-content: center; padding-top: 9px; padding-bottom: 9px; }
  .docbox-filter .fb-btn-search { flex: 1.6; }

  /* 모달: 좁은 화면에서 여백 최소화 */
  .modal-overlay { padding: 10px; }

  /* 조직도/결재자·참조자 선택: 모바일은 위(부서) / 아래(멤버) 세로 분할 */
  .oc-modal-body { flex-direction: column !important; }
  .oc-modal-body .kw-tree-panel {
    width: 100% !important; max-width: none !important; min-width: 0 !important;
    height: 150px; flex-shrink: 0; border-bottom: 1px solid var(--border);
    transition: height .2s ease;
  }
  .oc-modal-body .kw-tree-panel.expanded { height: 46vh; }
  .oc-modal-body .oc-tree-expand-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    flex-shrink: 0; width: 100%; border: none; border-top: 1px solid var(--border);
    background: #f3f4f6; color: var(--primary); font-size: 12px; font-weight: 600;
    padding: 9px; cursor: pointer;
  }
  .oc-modal-body .kw-resizer { display: none !important; }
  .oc-modal-body .kw-member-panel { width: 100%; flex: 1; min-height: 0; }
  .oc-modal-body .kw-mp-body { overflow-x: auto; }
  .oc-modal-body .kw-mp-header { flex-wrap: wrap; gap: 8px; }
  .oc-modal-body .kw-mp-search input { width: 100%; }

  /* 조직도 관리 페이지: 모바일은 위(부서)/아래(멤버) 세로 분할 + 확장 버튼 */
  .kw-org-page { flex-direction: column; height: calc(100vh - 150px); }
  .kw-org-page .kw-tree-panel {
    width: 100% !important; max-width: none !important; min-width: 0 !important;
    height: 200px; flex-shrink: 0; border-bottom: 1px solid var(--border);
    transition: height .2s ease;
  }
  .kw-org-page .kw-tree-panel.expanded { height: 50vh; }
  .kw-org-page .kw-resizer { display: none !important; }
  .kw-org-page .kw-member-panel { width: 100%; flex: 1; min-height: 0; }
  .kw-org-page .kw-mp-body { overflow-x: auto; }
  .kw-org-page .kw-mp-header { flex-wrap: wrap; gap: 8px; }
  .kw-org-page .oc-tree-expand-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    flex-shrink: 0; width: 100%; border: none; border-top: 1px solid var(--border);
    background: #f3f4f6; color: var(--primary); font-size: 12px; font-weight: 600;
    padding: 9px; cursor: pointer;
  }
}

/* ── 결재선 카드 ── */
.approval-card {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; cursor: grab; user-select: none; position: relative;
  transition: box-shadow .15s;
}
.approval-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.approval-card.dragging { opacity: .5; }
.approval-card-step {
  width: 22px; height: 22px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.approval-card-info { line-height: 1.3; }
.approval-card-name { font-size: 13px; font-weight: 600; }
.approval-card-dept { font-size: 11px; color: #9ca3af; }
.approval-card-remove {
  background: none; border: none; cursor: pointer; color: #9ca3af;
  font-size: 16px; line-height: 1; padding: 0 0 0 4px;
}
.approval-card-remove:hover { color: #e02424; }

/* ── 조직도 모달 ── */
.orgchart-dept { margin-bottom: 20px; }
.orgchart-dept-name {
  font-size: 12px; font-weight: 700; color: #6b7280; text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.orgchart-users { display: flex; flex-wrap: wrap; gap: 10px; }
.orgchart-user-card {
  width: 110px; padding: 12px 8px; border: 2px solid var(--border); border-radius: 10px;
  text-align: center; cursor: pointer; transition: all .15s; background: #fff;
  position: relative;
}
.orgchart-user-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(26,86,219,.15); }
.orgchart-user-card.selected { border-color: #3aaa35; background: #f0fdf4; }
.orgchart-step-badge {
  position: absolute; top: -8px; right: -8px;
  width: 20px; height: 20px; border-radius: 50%; background: #3aaa35;
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.orgchart-avatar {
  width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}
.orgchart-user-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.orgchart-user-dept { font-size: 11px; }

/* ── 연차 현황 카드 ── */
.leave-balance-card {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.leave-balance-loading { color: #9ca3af; font-size: 13px; }
.leave-balance-inner {}
.leave-stat-group { display: flex; gap: 24px; }
.leave-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 56px; }
.leave-num { font-size: 26px; font-weight: 700; color: #1e40af; line-height: 1; }
.leave-lbl { font-size: 11px; color: #6b7280; }
.leave-stat.used .leave-num { color: #9f580a; }
.leave-stat.remain .leave-num { color: #065f46; }
.leave-bar { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.leave-bar-fill { height: 100%; background: linear-gradient(90deg, #3aaa35, #1a56db); border-radius: 3px; transition: width .4s; }

/* ── 부서 칩 (사용자관리 페이지) ── */
.dept-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe;
  border-radius: 20px; padding: 4px 10px; font-size: 13px; font-weight: 500;
}
.dept-chip-del {
  background: none; border: none; cursor: pointer; color: #93c5fd;
  font-size: 15px; line-height: 1; padding: 0; margin-left: 2px;
  transition: color .1s;
}
.dept-chip-del:hover { color: #e02424; }

/* ── 부서 관리 ── */
.dept-mgr-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.dept-mgr-row:last-child { border-bottom: none; }
.dept-mgr-name { flex: 1; font-size: 14px; font-weight: 500; }
.dept-mgr-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── 조직도 페이지 ── */
.org-page { display: flex; flex-direction: column; align-items: center; padding: 24px 0; }

.org-top-row { display: flex; gap: 16px; justify-content: center; }

.org-connector-h {
  width: 2px; height: 32px; background: var(--border); margin: 0 auto;
}

.org-dept-row {
  display: flex; gap: 32px; justify-content: center; flex-wrap: wrap;
  padding-top: 0; position: relative;
}
.org-dept-row::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 80%; height: 2px; background: var(--border);
}

.org-dept-column {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  position: relative;
}
.org-dept-column::before {
  content: ''; position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 16px; background: var(--border);
}

.org-dept-label, .org-dept-name-badge {
  font-size: 11px; font-weight: 700; color: #374151; text-transform: uppercase;
  letter-spacing: .06em; padding: 4px 12px;
  background: #e5e7eb; border-radius: 20px; display: inline-block;
}

.org-dept-members { display: flex; flex-direction: column; align-items: center; gap: 0; }
.org-vert-line { width: 2px; height: 16px; background: var(--border); margin: 0 auto; }
.org-dept-header { margin-bottom: 8px; }

/* 계층 트리 노드 */
.org-tree-node {
  display: flex; flex-direction: column; align-items: center;
  position: relative;
}
.org-tree-node::before {
  content: ''; display: block; width: 2px; height: 16px;
  background: var(--border); margin: 0 auto;
}
.org-children {
  display: flex; gap: 32px; margin-top: 0; padding-top: 16px; position: relative;
  flex-wrap: wrap; justify-content: center;
}
.org-children::before {
  content: ''; position: absolute; top: 0; left: 10%; width: 80%; height: 2px;
  background: var(--border);
}
.org-children > .org-tree-node { padding-top: 0; }

.org-node-card {
  width: 140px; background: #fff; border: 2px solid var(--border);
  border-radius: 12px; padding: 14px 10px; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); transition: box-shadow .15s, transform .15s;
}
.org-node-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); transform: translateY(-2px); }
.org-node-card.ceo { width: 160px; }

.org-avatar {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.org-node-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.org-node-dept {
  font-size: 11px; border-radius: 4px; padding: 2px 6px;
  display: inline-block; margin-bottom: 2px;
}
.org-node-leave { font-size: 11px; color: #6b7280; margin-top: 6px; border-top: 1px solid #f3f4f6; padding-top: 6px; }
.org-node-leave b { color: #065f46; }

/* ── KakaoWork 스타일 조직도 페이지 ── */
.kw-org-page { display: flex; height: calc(100vh - 104px); gap: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }

/* 왼쪽 트리 패널 */
.kw-tree-panel { width: 260px; flex-shrink: 0; display: flex; flex-direction: column; background: #fff; min-width: 160px; max-width: 480px; }
.oc-tree-expand-btn { display: none; } /* 데스크톱에선 숨김(모바일 전용 부서패널 펼치기/접기) */

/* 리사이저 */
.kw-resizer {
  width: 6px; flex-shrink: 0; cursor: col-resize;
  background: var(--border); position: relative; transition: background .15s;
  display: flex; align-items: center; justify-content: center;
}
.kw-resizer:hover { background: #bfdbfe; }
.kw-resizer-active { background: var(--primary) !important; }
.kw-resizer::after {
  content: '⋮'; color: #9ca3af; font-size: 14px; line-height: 1;
  pointer-events: none;
}
.kw-resizer:hover::after { color: var(--primary); }
.kw-tree-search { padding: 12px; border-bottom: 1px solid var(--border); }
.kw-tree-search input { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; outline: none; background: #f9fafb; }
.kw-tree-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.kw-tree-footer { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; gap: 4px; align-items: center; }
.kw-tree-footer .kw-tf-btn { background: none; border: 1px solid var(--border); border-radius: 6px; width: 30px; height: 30px; cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center; color: #6b7280; }
.kw-tree-footer .kw-tf-btn:hover { background: #f3f4f6; color: var(--primary); }
.kw-tf-spacer { flex: 1; }

.kw-tree-node { user-select: none; }
.kw-tree-row { display: flex; align-items: center; padding: 5px 8px; cursor: pointer; gap: 3px; font-size: 13px; white-space: nowrap; overflow: hidden; user-select: none; }
.kw-tree-row:hover { background: #f3f4f6; }
.kw-tree-row.selected { background: #eff6ff; color: var(--primary); font-weight: 600; }
.kw-drag-handle { color: #d1d5db; font-size: 13px; cursor: grab; flex-shrink: 0; }
.kw-drag-handle:active { cursor: grabbing; }
.kw-drag-node[draggable] { cursor: default; }
/* 드롭 위치 표시 */
.kw-drop-before { border-top: 2px solid var(--primary) !important; background: #eff6ff !important; }
.kw-drop-after  { border-bottom: 2px solid var(--primary) !important; background: #eff6ff !important; }
.kw-drop-into   { background: #dbeafe !important; outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 4px; }
.kw-tree-toggle { width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; color: #9ca3af; font-size: 11px; flex-shrink: 0; cursor: pointer; }
.kw-tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kw-tree-count { font-size: 11px; color: #9ca3af; flex-shrink: 0; }

/* 오른쪽 멤버 패널 */
.kw-member-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.kw-mp-header { padding: 14px 20px 10px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.kw-mp-title { font-size: 15px; font-weight: 700; }
.kw-mp-subtitle { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.kw-mp-search { padding: 0 4px; }
.kw-mp-search input { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; outline: none; width: 240px; }
.kw-mp-body { flex: 1; overflow-y: auto; }
.kw-mp-footer { padding: 10px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.kw-mp-footer-btn { font-size: 13px; color: var(--primary); background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.kw-mp-footer-btn:hover { background: #f3f4f6; }
.kw-mp-footer-count { font-size: 13px; color: #6b7280; }

/* 멤버 테이블 행 */
.kw-member-table { width: 100%; border-collapse: collapse; }
.kw-member-table th { font-size: 12px; color: #6b7280; font-weight: 500; padding: 8px 16px; border-bottom: 1px solid var(--border); text-align: left; background: #fafafa; white-space: nowrap; }
.kw-member-table td { padding: 10px 16px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; font-size: 13px; white-space: nowrap; }
.kw-member-table tr:hover td { background: #f9fafb; }
.kw-member-avatar { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0; }
.kw-member-name-cell { display: flex; align-items: center; gap: 10px; }
.kw-member-name { font-weight: 600; font-size: 13px; white-space: nowrap; }
.kw-member-sub { font-size: 11px; color: #9ca3af; margin-top: 1px; white-space: nowrap; }
.kw-member-tag { display: inline-block; font-size: 10px; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; color: #6b7280; margin-left: 4px; }
.kw-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.kw-status-active { background: #0e9f6e; }
.kw-status-inactive { background: #d1d5db; }
.kw-3dot { background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 4px; color: #9ca3af; font-size: 18px; }
.kw-3dot:hover { background: #f3f4f6; color: #374151; }

/* ── KakaoWork 스타일 멤버 관리 (admin 페이지) ── */
.kw-admin-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.kw-admin-search { flex: 1; max-width: 300px; }
.kw-admin-search input { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; font-size: 13px; outline: none; }
.kw-admin-btns { display: flex; gap: 8px; margin-left: auto; }
.kw-admin-table { width: 100%; border-collapse: collapse; }
.kw-admin-table th { font-size: 12px; color: #6b7280; font-weight: 500; padding: 10px 14px; border-bottom: 2px solid var(--border); text-align: left; background: #fafafa; white-space: nowrap; cursor: pointer; }
.kw-admin-table th:hover { color: var(--primary); }
.kw-admin-table td { padding: 10px 14px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; font-size: 13px; }
.kw-admin-table tr:hover td { background: #f9fafb; }

/* ── 멤버 모달 (사용자 추가/편집) ── */
.um-photo-area { display: flex; flex-direction: column; align-items: center; margin-bottom: 20px; }
.um-photo-wrap { position: relative; width: 80px; height: 80px; cursor: pointer; }
.um-photo-placeholder { width: 80px; height: 80px; border-radius: 16px; background: #e5e7eb; display: flex; align-items: center; justify-content: center; }
.um-photo-edit { position: absolute; bottom: -4px; right: -4px; width: 24px; height: 24px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; }
.um-photo-label { font-size: 12px; color: #9ca3af; margin-top: 6px; }
.um-radio-group { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.um-radio { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.um-org-row { display: flex; gap: 8px; align-items: center; }
.um-org-btn { flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: #374151; text-align: left; }
.um-org-btn:hover { border-color: var(--primary); }
.um-org-icon { color: #9ca3af; }

/* 조직 선택 모달 트리 */
.uot-node { user-select: none; }
.uot-row { display: flex; align-items: center; padding: 6px 16px; cursor: pointer; gap: 6px; font-size: 13px; }
.uot-row:hover { background: #f3f4f6; }
.uot-row.selected { background: #eff6ff; color: var(--primary); font-weight: 600; }
.uot-toggle { width: 14px; flex-shrink: 0; color: #9ca3af; font-size: 10px; }
.uot-name { flex: 1; }

/* ── 직책/직위 관리 ── */
.pos-list { border-bottom: 1px solid var(--border); }
.pos-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid #f3f4f6; cursor: grab; transition: background .1s;
}
.pos-item:hover { background: #f9fafb; }
.pos-item:active { cursor: grabbing; }
.pos-drag { color: #d1d5db; font-size: 16px; cursor: grab; }
.pos-order { width: 20px; font-size: 12px; color: #9ca3af; text-align: center; flex-shrink: 0; }
.pos-name { flex: 1; font-size: 13px; font-weight: 500; }
.pos-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.pos-item:hover .pos-actions { opacity: 1; }
.pos-btn { background: none; border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; cursor: pointer; font-size: 12px; }
.pos-btn:hover { background: #f3f4f6; }
.pos-btn-del:hover { background: #fef2f2; border-color: #fca5a5; }
.pos-add-row { display: flex; gap: 8px; padding: 10px 16px; align-items: center; }

.pos-usage-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pos-usage-name { width: 70px; font-size: 13px; font-weight: 500; flex-shrink: 0; }
.pos-usage-bar-wrap { flex: 1; height: 6px; background: #f3f4f6; border-radius: 3px; overflow: hidden; }
.pos-usage-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; min-width: 2px; }
.pos-usage-count { width: 28px; font-size: 12px; color: #6b7280; text-align: right; flex-shrink: 0; }
.pos-usage-avatars { display: flex; align-items: center; gap: 3px; }
.pos-usage-av {
  width: 22px; height: 22px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* ── 조직도 차트 뷰 ── */
.oc-toolbar { display: flex; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.oc-zoom-btns { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.oc-zoom-btn {
  width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; color: #374151;
  line-height: 1;
}
.oc-zoom-btn:hover { background: #f3f4f6; border-color: var(--primary); color: var(--primary); }
.oc-zoom-label { font-size: 12px; color: #6b7280; min-width: 36px; text-align: center; }
/* 스크롤 영역 */
.oc-scroll-wrap { overflow: auto; padding: 16px 0 40px; }
/* 줌 래퍼: min-width:max-content 로 스크롤 영역 확보 → 좌측 잘림 방지 */
.oc-zoom-wrap {
  transform-origin: top center; transition: transform .2s;
  display: flex; justify-content: center;
  min-width: max-content; padding: 0 80px;
}

/* 트리 루트 */
.oc-tree { display: inline-flex; flex-direction: column; align-items: center; padding-bottom: 24px; }

/* 노드 공통 */
.oc-node { display: flex; flex-direction: column; align-items: center; position: relative; }

/* ── 연결선 ─────────────────────────────────────────────── */
/* 자식 컨테이너: margin-top 으로 부모박스와 간격 확보 */
.oc-children {
  display: flex; flex-direction: row; align-items: flex-start;
  position: relative; margin-top: 44px;
}
/* 부모 박스 하단 → 수평선 세로 연결선 (border 사용 → 인쇄 시 항상 출력) */
.oc-children::before {
  content: ''; position: absolute; top: -44px; left: calc(50% - 1px);
  width: 0; height: 44px; border-left: 2px solid #94a3b8;
}
/* 각 자식 노드: 수평선→박스 세로선(::before) + 수평선(::after) */
.oc-children > .oc-node { padding: 44px 20px 0; position: relative; }
.oc-children > .oc-node::before {
  content: ''; position: absolute; top: 0; left: calc(50% - 1px);
  width: 0; height: 44px; border-left: 2px solid #94a3b8;
}
.oc-children > .oc-node::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 0; border-top: 2px solid #94a3b8;
}
.oc-children > .oc-node:first-child::after  { left: 50%; }
.oc-children > .oc-node:last-child::after   { right: 50%; }
.oc-children > .oc-node:only-child::after   { display: none; }
/* ─────────────────────────────────────────────────────── */

/* 노드 박스 */
.oc-box {
  width: 148px; border: 1.5px solid #cbd5e1; border-radius: 8px;
  overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.09);
  background: #fff; flex-shrink: 0; position: relative; z-index: 1;
  transition: box-shadow .15s, transform .15s; cursor: default;
}
.oc-box:hover { box-shadow: 0 4px 16px rgba(0,0,0,.15); transform: translateY(-2px); }
.oc-box-root { width: 168px; }
.oc-box-header {
  background: #1a56db; color: #fff; font-size: 12px; font-weight: 700;
  padding: 7px 10px; text-align: center; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
.oc-box-body { padding: 10px 8px 8px; text-align: center; }
.oc-head-name { font-size: 13px; font-weight: 700; margin-bottom: 6px; text-align: center; }
.oc-head-inline-title { font-size: 11px; font-weight: 400; color: #6b7280; }
.oc-head-title { font-size: 11px; color: #6b7280; margin-bottom: 8px; line-height: 1.4; }
.oc-member-list { border-top: 1px solid #f3f4f6; padding-top: 5px; margin-bottom: 5px; }
.oc-member-row { font-size: 11px; color: #374151; line-height: 1.8; text-align: center; }
.oc-counts { font-size: 11px; color: #374151; border-top: 1px solid #f3f4f6; padding-top: 6px; }
.oc-cnt-sep { color: #d1d5db; margin: 0 3px; }


/* ── 부서 관리 색상 스와치 ── */
.oc-cp-swatch {
  width: 24px; height: 24px; border-radius: 5px; border: 2px solid transparent;
  cursor: pointer; transition: transform .1s, border-color .1s;
}
.oc-cp-swatch:hover { transform: scale(1.18); border-color: rgba(0,0,0,.2); }
.oc-cp-swatch.oc-cp-active { border-color: #1a56db; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a56db; }

/* ── 컨텍스트 메뉴 ── */
.ctx-item { padding: 8px 16px; cursor: pointer; font-size: 13px; color: #374151; }
.ctx-item:hover { background: #f3f4f6; }

/* ── 인쇄/PDF 출력 ── */
@media print {
  body { background: #fff !important; color: #000 !important; font-size: 12px; }
  #sidebar, #header, .no-print { display: none !important; }
  #main { display: block !important; overflow: visible; }
  #content { padding: 0; overflow: visible; }
  #doc-detail-wrap { max-width: 100% !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
  .btn { display: none !important; }
  .badge { border: 1px solid #ccc !important; }
  a { color: #000 !important; text-decoration: none !important; }
  .timeline-icon { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .doc-header { background: #f5f5f5 !important; }

  /* 조직도 인쇄: print-area만 표시, 나머지 전부 숨김 */
  body > *:not(#oc-print-area) { display: none !important; }
  #oc-print-area { display: block !important; overflow: visible !important; }
  @page { size: A3 landscape; margin: 8mm; }

  /* 인쇄 전용 영역 overflow 해제 */
  #oc-print-tree-wrap,
  #oc-print-tree-wrap .oc-tree,
  #oc-print-tree-wrap .oc-node,
  #oc-print-tree-wrap .oc-children { overflow: visible !important; }

  /* 인쇄용 박스 소형화 */
  #oc-print-area .oc-box        { width: 108px !important; box-shadow: none !important; }
  #oc-print-area .oc-box-root   { width: 124px !important; }
  #oc-print-area .oc-box-header {
    font-size: 10px !important; padding: 5px 6px !important;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  #oc-print-area .oc-box-body   { padding: 6px 5px 5px !important; }
  #oc-print-area .oc-head-name  { font-size: 10px !important; margin-bottom: 1px !important; }
  #oc-print-area .oc-head-title { font-size: 8px !important; margin-bottom: 4px !important; }
  #oc-print-area .oc-counts     { font-size: 8px !important; padding-top: 3px !important; }

  /* 연결선 간격 축소 + border 재정의 (혹시 모를 override) */
  #oc-print-area .oc-children { margin-top: 28px !important; }
  #oc-print-area .oc-children::before {
    top: -28px !important; height: 28px !important;
    border-left: 1.5px solid #555 !important; width: 0 !important;
  }
  #oc-print-area .oc-children > .oc-node { padding: 28px 6px 0 !important; }
  #oc-print-area .oc-children > .oc-node::before {
    height: 28px !important;
    border-left: 1.5px solid #555 !important; width: 0 !important;
  }
  #oc-print-area .oc-children > .oc-node::after {
    border-top: 1.5px solid #555 !important; height: 0 !important;
  }
}

/* 인쇄 전용 영역 (평소에는 숨김) */
#oc-print-area {
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans KR', sans-serif;
  background: #fff;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.oc-print-header { font-size: 11px; color: #6b7280; margin-bottom: 10px; }
#oc-print-tree-wrap { overflow: visible; }
