:root {
  --primary:           #0d9488;
  --primary-hover:     #0f766e;
  --primary-light:     #f0fdfa;
  --bg-topbar:         #1e293b;
  --bg-sidebar:        #f8fafc;
  --bg-content:        #ffffff;
  --border:            #e2e8f0;
  --text-primary:      #0f172a;
  --text-secondary:    #64748b;
  --text-muted:        #94a3b8;
  --header-h:          52px;
  --sidebar-width:     240px;   /* 확장 기본값(JS 드래그/복원으로 갱신) */
  --sidebar-rail:      60px;    /* 레일(아이콘) 폭 */
  --sidebar-min:       180px;
  --sidebar-max:       360px;
}
body.sidebar-collapsed { --sidebar-width: var(--sidebar-rail); }

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-content);
  color: var(--text-primary);
  font-size: 14px;
}

/* ── App Header (전체 폭, 고정) ─────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-content);
  border-bottom: 1px solid var(--border);
  z-index: 200;
}
.app-header .sidebar-toggle { font-size: 18px; }
.header-spacer { flex: 1; }
.header-user { display: flex; align-items: center; gap: 14px; }
.header-user .hu-name { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.header-user a.hu-link { font-size: 13px; color: var(--text-secondary); text-decoration: none; padding: 4px 8px; border-radius: 6px; }
.header-user a.hu-link:hover { background: var(--border); color: var(--text-primary); }
.header-user .hu-logout {
  display: flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  font-size: 13px; cursor: pointer; padding: 5px 12px; border-radius: 6px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.header-user .hu-logout:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

/* ── Sidebar ──────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-h); left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
body.resizing .sidebar, body.resizing .main-content { transition: none; }
body.resizing { user-select: none; cursor: col-resize; }

/* 드래그 리사이저 (확장 모드에서만) */
.sidebar-resizer {
  position: absolute; top: 0; right: 0; width: 5px; height: 100%;
  cursor: col-resize; z-index: 110;
}
.sidebar-resizer:hover { background: var(--primary-light); }
body.sidebar-collapsed .sidebar-resizer { display: none; }

.sidebar-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  min-width: 0;
}

.brand-icon {
  background: var(--primary);
  color: #fff;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 800;
  font-size: 11px;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.brand-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  transition: opacity 0.15s ease;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--border);
  color: var(--text-primary);
}

.sidebar-menu-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
}

/* 헤더 사용자 아바타 */
.user-avatar {
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Sidebar Items ────────────────────────── */
/* 단독 메뉴 (Home, Notice) */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  margin: 1px 8px;
  transition: background 0.12s, color 0.12s;
}
.sidebar-item:hover { background: var(--border); color: var(--text-primary); }
.sidebar-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* ── Accordion Group ──────────────────────── */
.sidebar-group { }

.sidebar-group-btn {
  display: flex;
  align-items: center;
  width: calc(100% - 16px);
  margin: 1px 8px;
  padding: 9px 10px 9px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  transition: background 0.12s, color 0.12s;
  gap: 0;
}
.sidebar-group-btn:hover { background: var(--border); color: var(--text-primary); }

/* Arrow */
.s-arrow {
  margin-left: auto;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.sidebar-group:not(.open) .s-arrow { transform: rotate(-90deg); }

/* Submenu container */
.sidebar-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease;
}
.sidebar-group.open .sidebar-sub { max-height: 400px; }

/* Subitem */
.sidebar-subitem {
  display: flex;
  align-items: center;
  padding: 8px 12px 8px 32px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
  margin: 1px 8px;
  transition: background 0.12s, color 0.12s;
  gap: 0;
}
.sidebar-subitem:hover { background: var(--border); color: var(--text-primary); }
.sidebar-subitem.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* Shared icon/label */
.s-icon {
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  font-size: 14px;
  margin-right: 8px;
}
.s-label { flex: 1; transition: opacity 0.15s ease; white-space: nowrap; }

/* Divider */
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 12px;
}

/* ── Rail(Collapsed) Sidebar — 하위 아이콘 노출 ─ */
body.sidebar-collapsed .s-label,
body.sidebar-collapsed .s-arrow {
  opacity: 0 !important;
  pointer-events: none;
  width: 0;
  display: none !important;
}

/* 그룹 헤더 + 단독 메뉴: 아이콘만 가운데 */
body.sidebar-collapsed .sidebar-item,
body.sidebar-collapsed .sidebar-group-btn {
  justify-content: center;
  padding: 9px 0;
  margin: 1px 6px;
  width: auto;
}
/* 하위 메뉴: 숨기지 않고 아이콘만 평탄하게 노출 */
body.sidebar-collapsed .sidebar-sub {
  overflow: visible;
  max-height: none !important;
  display: block !important;
}
body.sidebar-collapsed .sidebar-subitem {
  justify-content: center;
  padding: 8px 0;
  margin: 1px 6px;
}
body.sidebar-collapsed .s-icon { margin-right: 0; }
/* 그룹 접힘(open 아님)이어도 레일에선 아이콘 노출 */
body.sidebar-collapsed .sidebar-group:not(.open) .sidebar-sub { display: block !important; }
body.sidebar-collapsed .sidebar-divider { margin: 6px 14px; }

/* ── Main Content ─────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 24px;
  padding-top: calc(var(--header-h) + 24px);  /* 고정 헤더 높이 확보 */
  min-height: 100vh;
  transition: margin-left 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Breadcrumb ───────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.breadcrumb .sep { color: var(--text-muted); }
.breadcrumb .current { color: var(--text-primary); font-weight: 500; }

/* ── Card ─────────────────────────────────── */
.card {
  background: var(--bg-content);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
  text-decoration: none;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-sidebar); }
.btn-danger    { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ── Table ────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--bg-sidebar);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  text-align: left;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: var(--bg-sidebar); }

/* ── Modal ────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 28px;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 20px; }

/* ── Form ─────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.form-input, .form-select {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; color: var(--text-primary); background: #fff;
  outline: none; transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); }

/* ── 조회조건 필터 바 (우측 정렬, 줄바꿈 허용) ─── */
.filter-bar { display:flex; gap:8px; align-items:flex-end; justify-content:flex-end; flex-wrap:wrap; margin-bottom:14px; }
.filter-bar .fb-field { display:flex; flex-direction:column; }
.filter-bar label { font-size:11px; color:var(--text-secondary); font-weight:600; margin-bottom:3px; }
.filter-bar input, .filter-bar select { padding:4px 8px; font-size:13px; width:140px; }
.list-pager { display:flex; justify-content:center; align-items:center; gap:6px; margin-top:12px; }

/* ── 멤버(사용자) 다중 선택 피커 ─── */
.member-picker { position:relative; }
.member-picker .mp-chips { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:6px; }
.member-picker .mp-chip { display:inline-flex; align-items:center; gap:4px; background:#e0f2fe; color:#075985; border-radius:99px; padding:2px 8px; font-size:12px; }
.member-picker .mp-chip small { color:#0369a1; }
.member-picker .mp-chip a { cursor:pointer; color:#0369a1; font-weight:700; text-decoration:none; }
.member-picker .mp-input { width:100%; }
.member-picker .mp-dd { position:absolute; left:0; right:0; z-index:50; background:#fff; border:1px solid var(--border); border-radius:8px; margin-top:2px; max-height:220px; overflow-y:auto; box-shadow:0 6px 20px rgba(0,0,0,.10); }
.member-picker .mp-opt { padding:7px 12px; font-size:13px; cursor:pointer; }
.member-picker .mp-opt:hover { background:var(--bg-secondary,#f1f5f9); }
.member-picker .mp-opt small { color:var(--text-muted); }
.member-picker .mp-empty { color:var(--text-muted); cursor:default; }

/* ── 모달 닫기(×) 버튼 ─── */
.modal-close-x { position:absolute; top:10px; right:12px; width:28px; height:28px; padding:0; border:none; background:transparent; color:var(--text-muted); font-size:17px; line-height:1; cursor:pointer; border-radius:6px; z-index:2; }
.modal-close-x:hover { background:var(--bg-secondary,#f1f5f9); color:var(--text-primary); }

/* ── Rail Tooltip (JS 위치 지정) ──────────────── */
.rail-tooltip {
  position: fixed;
  background: #0f172a; color: #fff;
  font-size: 12px; font-weight: 500;
  padding: 5px 9px; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
  opacity: 0; transition: opacity 0.1s ease;
  z-index: 300;
}
.rail-tooltip.show { opacity: 1; }

/* ── 내정보 페이지 ────────────────────────────── */
.mi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .mi-grid { grid-template-columns: 1fr; } }
.mi-field { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.mi-field:last-child { border-bottom: none; }
.mi-field .k { color: var(--text-muted); }
.mi-field .v { color: var(--text-primary); font-weight: 500; }
.chip { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--primary-light); color: var(--primary); font-weight: 600; margin: 3px 4px 3px 0; }
.chip-muted { background: #e2e8f0; color: #475569; }
.req-badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.rb-pending { background: #fef3c7; color: #92400e; }
.rb-approved { background: #d1fae5; color: #065f46; }
.rb-rejected { background: #fee2e2; color: #b91c1c; }

/* 비밀번호 변경 — 글자 없는 작은 열쇠(은닉) */
.pw-key-btn {
  background: none; border: none; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px;
  opacity: 0.28; transition: opacity 0.15s;
}
.pw-key-btn:hover { opacity: 0.7; }
