/* ── 리셋 & 변수 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4f6ef7;
  --primary-dark: #3a57e8;
  --primary-light: #eef0fe;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --danger:      #ef4444;
  --danger-light: #fee2e2;
  --sidebar-w: 230px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 20px rgba(0,0,0,.1);
}

/* 로딩 오버레이 */
#loadingOverlay {
  position: fixed; inset: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

body {
  font-family: 'Segoe UI', 'Apple SD Gothic Neo', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}

/* ── 레이아웃 ── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── 사이드바 ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding-bottom: 12px;
}

.sidebar-top {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.3px;
}
.logo svg { color: var(--primary); flex-shrink: 0; }

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 10px 18px 4px;
}

/* 사이드바 부서원 버튼 */
.nav-member {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--gray-400);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
  margin: 1px 8px;
  width: calc(100% - 16px);
}
.nav-member:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-member.active { background: rgba(79,110,247,.18); color: #fff; }
.nav-member.active .avatar-circle { opacity: 1; }

.avatar-circle {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.all-icon { background: rgba(255,255,255,.12); }

.sidebar-bottom {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* 현재 접속자 */
.current-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background .15s;
}
.current-user:hover { background: rgba(255,255,255,.06); }

.current-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  background: #475569;
  flex-shrink: 0;
}

.current-user-info { flex: 1; min-width: 0; }
.current-user-name { display: block; font-size: 13px; font-weight: 700; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.current-user-role { display: block; font-size: 11px; color: #64748b; }

.boss-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: 4px;
  vertical-align: middle;
}

/* 접속자 선택 목록 */
.login-member-list { display: flex; flex-direction: column; gap: 6px; }

.login-member-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1.5px solid var(--gray-200);
  background: #fff;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  width: 100%;
}
.login-member-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.login-member-btn.selected { border-color: var(--primary); background: var(--primary-light); }

.manage-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--gray-400);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.manage-btn:hover { background: rgba(255,255,255,.06); color: #fff; }

/* ── 메인 ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  gap: 16px;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.header-view { display: flex; align-items: center; gap: 12px; }

.page-title { font-size: 18px; font-weight: 700; color: var(--gray-800); white-space: nowrap; }
.member-role-header { font-size: 12.5px; color: var(--gray-400); }

/* 월 네비게이션 */
.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gray-100);
  border-radius: 8px;
  padding: 4px 6px;
}
.month-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-500);
  transition: all .15s;
}
.month-btn:hover { background: var(--gray-200); color: var(--gray-700); }
.month-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
  min-width: 80px;
  text-align: center;
}

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px; border: none;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--gray-100); color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; border: none; cursor: pointer; transition: all .15s;
  background: none; color: var(--gray-400);
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-icon.btn-del:hover { background: var(--danger-light); color: var(--danger); }

/* ── 콘텐츠 ── */
.content { flex: 1; overflow-y: auto; padding: 24px 28px; }
.view { display: none; }
.view.active { display: block; }

/* ── 공지 패널 ── */
.notice-panel {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.notice-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: #92400e;
}

.notice-label {
  font-size: 13px;
  font-weight: 700;
  flex: 1;
}

.notice-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #fcd34d;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.notice-edit-btn:hover { background: #fde68a; }

.notice-content {
  font-size: 13.5px;
  color: #78350f;
  line-height: 1.9;
  white-space: pre-wrap;
}

.notice-edit-area textarea {
  width: 100%;
  border: 1.5px solid #fcd34d;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--gray-700);
  background: #fff;
  outline: none;
  resize: vertical;
  font-family: inherit;
  line-height: 1.8;
}
.notice-edit-area textarea:focus { border-color: #f59e0b; }

.notice-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* ── 사이트 패널 ── */
.sites-panel {
  background: #f0fdf4;
  border-color: #86efac;
  margin-top: -4px;
}
.sites-panel .notice-bar { color: #166534; }
.sites-panel .notice-edit-btn {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.sites-panel .notice-edit-btn:hover { background: #bbf7d0; }

.sites-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.site-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 7px 12px;
  min-width: 0;
}

.site-favicon {
  color: #16a34a;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.site-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.site-name {
  font-size: 13px;
  font-weight: 700;
  color: #166534;
  text-decoration: none;
  white-space: nowrap;
}
.site-name:hover { text-decoration: underline; }

.site-desc {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
}

.site-actions {
  display: flex;
  gap: 2px;
  margin-left: 4px;
  flex-shrink: 0;
}

/* ── 전체 보기 그리드 ── */
.all-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.all-member-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.all-member-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background .15s;
}
.all-member-card-header:hover { background: var(--gray-50); }
.all-member-card-header .name { font-weight: 700; font-size: 14px; }
.all-member-card-header .role { font-size: 12px; color: var(--gray-400); }
.all-member-contact { font-size: 11.5px; color: var(--primary); margin-top: 1px; }
.task-count-badge {
  margin-left: auto;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
}

.all-member-tasks { padding: 8px 0; min-height: 48px; }

.all-task-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--gray-50);
  font-size: 13px;
}
.all-task-row:last-child { border-bottom: none; }

.task-date-dot {
  margin-top: 5px;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.all-task-info { flex: 1; min-width: 0; }
.all-task-title { font-weight: 600; font-size: 13px; color: var(--gray-700); }
.all-task-date  { font-size: 11.5px; color: var(--gray-400); margin-top: 1px; }
.all-task-memo  { font-size: 12px; color: var(--gray-400); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.all-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--gray-300);
}

/* ── 개인 업무 뷰 ── */
.member-tasks-wrap { max-width: 760px; }

/* 월 섹션 */
.month-section { margin-bottom: 20px; }

.month-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 8px;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 0;
}

.month-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.month-section-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--gray-700);
  min-width: 36px;
}

.month-task-cnt {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 99px;
}

.btn-add-task {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 5px 12px;
  border-radius: 7px;
  border: 1.5px dashed var(--gray-300);
  background: none;
  color: var(--gray-400);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.btn-add-task:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.td-empty {
  padding: 14px 16px !important;
  font-size: 13px;
  color: var(--gray-300);
  text-align: center;
}

/* 업무 테이블 */
.task-table {
  width: 100%;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
.task-table th {
  padding: 10px 16px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  text-align: left;
}
.task-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.task-table tr:last-child td { border-bottom: none; }
.task-table tr:hover td { background: var(--gray-50); }

.td-date  { width: 90px; font-size: 13px; color: var(--gray-500); white-space: nowrap; padding-top: 13px; }
.td-title { font-weight: 600; font-size: 13.5px; }
.td-memo  { font-size: 12.5px; color: var(--gray-400); margin-top: 3px; }
.td-actions { width: 70px; text-align: right; }

/* 빈 상태 */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-300);
}
.empty-state svg { display: block; margin: 0 auto 12px; }
.empty-state p { font-size: 14px; }

/* ── 부서원 관리 ── */
.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.member-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.member-card .avatar-circle { width: 52px; height: 52px; font-size: 20px; }
.member-card-name  { font-size: 15px; font-weight: 700; margin-top: 4px; }
.member-card-role  { font-size: 12px; color: var(--gray-400); }
.member-card-email { font-size: 12px; color: var(--primary); }
.member-card-cnt   { font-size: 12px; color: var(--gray-500); background: var(--gray-100); padding: 3px 10px; border-radius: 99px; margin-top: 4px; }
.member-card-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── 모달 ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.38);
  display: none; align-items: center; justify-content: center;
  z-index: 999; padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease;
}
.modal-sm { max-width: 380px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 0;
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); padding: 4px; border-radius: 6px;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }

.modal-body   { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ── 폼 ── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 12.5px; font-weight: 600; color: var(--gray-600); }
.required { color: var(--danger); }

input[type="text"],
input[type="tel"],
input[type="date"],
textarea {
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--gray-800);
  outline: none;
  transition: border-color .15s;
  background: #fff;
  width: 100%;
  font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform .1s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--gray-800); transform: scale(1.1); }

/* ── 토스트 ── */
.toast {
  position: fixed; bottom: 22px; right: 22px;
  background: var(--gray-900); color: #fff;
  padding: 11px 18px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: all .22s; z-index: 9999;
  pointer-events: none; max-width: 300px;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── 반응형 ── */
@media (max-width: 760px) {
  :root { --sidebar-w: 58px; }
  .logo span, .nav-member span, .manage-btn span,
  .sidebar-section-label { display: none; }
  .nav-member { justify-content: center; padding: 8px 0; }
  .manage-btn { justify-content: center; }
  .content { padding: 16px; }
  .all-grid { grid-template-columns: 1fr; }
}
