* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #F1F5F9;
  color: #1E293B;
  height: 100vh;
  overflow: hidden;
}

/* ─── 로그인 ─────────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 50%, #3B82F6 100%);
}

.login-box {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo h1 { font-size: 22px; font-weight: 700; color: #1E293B; margin-top: 12px; }
.login-logo p { font-size: 13px; color: #64748B; margin-top: 4px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 6px; }
.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #E2E8F0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}
.form-group input:focus { border-color: #2563EB; }

/* ─── 버튼 ───────────────────────────────────────────────── */
.btn-primary {
  background: #2563EB;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: #1D4ED8; }
.btn-full { width: 100%; padding: 12px; font-size: 15px; }

.btn-secondary {
  background: white;
  color: #374151;
  border: 1.5px solid #E2E8F0;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-right: 8px;
}
.btn-secondary:hover { background: #F8FAFC; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: #64748B;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: #F1F5F9; color: #1E293B; }

.error-msg { color: #EF4444; font-size: 13px; margin-top: 8px; padding: 8px 12px; background: #FEF2F2; border-radius: 6px; }

/* ─── 앱 레이아웃 ────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
}

/* ─── 사이드바 ───────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: #1E293B;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid #334155;
}

.user-info { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px;
  background: #2563EB;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 14px;
  flex-shrink: 0;
}
.user-email { font-size: 12px; color: #E2E8F0; font-weight: 500; word-break: break-all; }
.user-domain { font-size: 11px; color: #64748B; }

.btn-compose {
  margin: 16px;
  background: #2563EB;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}
.btn-compose:hover { background: #1D4ED8; }

.folder-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-section-title { font-size: 10px; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: 0.08em; padding: 8px 16px 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #94A3B8;
  text-decoration: none;
  font-size: 13px;
  border-radius: 0;
  transition: all 0.15s;
  cursor: pointer;
  position: relative;
}
.nav-item:hover { background: #334155; color: #E2E8F0; }
.nav-item.active { background: #2563EB; color: white; }
.nav-item svg { flex-shrink: 0; }

.badge {
  margin-left: auto;
  background: #EF4444;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer { border-top: 1px solid #334155; padding: 8px 0; }

/* ─── 메인 콘텐츠 ────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ─── 메일 목록 패널 ─────────────────────────────────────── */
.mail-list-panel {
  width: 360px;
  background: white;
  border-right: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-header h2 { font-size: 16px; font-weight: 600; color: #1E293B; white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #F8FAFC;
  border: 1.5px solid #E2E8F0;
  border-radius: 8px;
  padding: 6px 10px;
  flex: 1;
  max-width: 200px;
}
.search-box svg { color: #94A3B8; flex-shrink: 0; }
.search-box input { border: none; background: none; outline: none; font-size: 13px; width: 100%; }

.mail-list { flex: 1; overflow-y: auto; }

.mail-item {
  padding: 14px 16px;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.mail-item:hover { background: #F8FAFC; }
.mail-item.active { background: #EFF6FF; border-left: 3px solid #2563EB; }
.mail-item.unread .mail-subject { font-weight: 600; color: #1E293B; }
.mail-item.unread::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  background: #2563EB;
  border-radius: 50%;
}

.mail-from { font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-subject { font-size: 13px; color: #374151; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-date { font-size: 11px; color: #94A3B8; }

.loading { padding: 40px; text-align: center; color: #94A3B8; font-size: 14px; }
.empty { padding: 40px; text-align: center; color: #94A3B8; font-size: 14px; }

.pagination {
  padding: 12px 16px;
  border-top: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.page-btn {
  padding: 6px 12px;
  border: 1.5px solid #E2E8F0;
  border-radius: 6px;
  background: white;
  font-size: 13px;
  cursor: pointer;
  color: #374151;
}
.page-btn:hover { background: #F8FAFC; }
.page-btn.active { background: #2563EB; color: white; border-color: #2563EB; }
.page-info { font-size: 12px; color: #64748B; }

/* ─── 메일 상세 패널 ─────────────────────────────────────── */
.mail-detail-panel {
  flex: 1;
  background: white;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #94A3B8;
}
.empty-state p { font-size: 14px; }

#mail-content {
  padding: 32px;
  flex: 1;
}

.mail-detail-header { margin-bottom: 24px; }
.mail-detail-subject { font-size: 22px; font-weight: 700; color: #1E293B; margin-bottom: 16px; line-height: 1.4; }
.mail-meta { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: #F8FAFC; border-radius: 10px; margin-bottom: 8px; }
.mail-meta-row { display: flex; gap: 8px; font-size: 13px; }
.mail-meta-label { color: #64748B; font-weight: 500; min-width: 60px; }
.mail-meta-value { color: #374151; }

.mail-actions { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.mail-actions button {
  padding: 7px 14px;
  border: 1.5px solid #E2E8F0;
  border-radius: 7px;
  background: white;
  font-size: 13px;
  cursor: pointer;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.mail-actions button:hover { background: #F8FAFC; border-color: #CBD5E1; }
.mail-actions .btn-delete:hover { background: #FEF2F2; border-color: #FECACA; color: #EF4444; }

.mail-body {
  font-size: 14px;
  line-height: 1.7;
  color: #374151;
  border-top: 1px solid #E2E8F0;
  padding-top: 24px;
}
.mail-body img { max-width: 100%; }

.mail-attachments { margin-top: 24px; padding-top: 16px; border-top: 1px solid #E2E8F0; }
.mail-attachments h4 { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 10px; }
.attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  font-size: 12px;
  color: #374151;
  margin: 4px;
  cursor: pointer;
}
.attachment-item:hover { background: #EFF6FF; border-color: #BFDBFE; }

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

.modal-box {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }

/* ─── 메일 작성 ──────────────────────────────────────────── */
.compose-box { width: 680px; }

.compose-fields { padding: 16px 20px 0; }
.compose-field { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid #F1F5F9; }
.compose-field label { font-size: 12px; font-weight: 500; color: #64748B; min-width: 70px; }
.compose-field input { flex: 1; border: none; outline: none; font-size: 14px; color: #1E293B; }

.compose-toolbar {
  padding: 8px 20px;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  gap: 4px;
}
.toolbar-btn {
  padding: 4px 10px;
  border: 1px solid #E2E8F0;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
}
.toolbar-btn:hover { background: #F8FAFC; }

.compose-body {
  flex: 1;
  padding: 16px 20px;
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  outline: none;
  color: #1E293B;
}
.compose-body:empty::before { content: attr(placeholder); color: #94A3B8; }

.compose-footer {
  padding: 12px 20px;
  border-top: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.attach-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #64748B;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #E2E8F0;
}
.attach-btn:hover { background: #F8FAFC; }

.attachment-list { display: flex; flex-wrap: wrap; gap: 6px; }
.attach-tag {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  color: #1D4ED8;
  display: flex;
  align-items: center;
  gap: 4px;
}
.attach-tag button { background: none; border: none; cursor: pointer; color: #64748B; font-size: 12px; }

/* ─── 계정 관리 ──────────────────────────────────────────── */
.admin-box { width: 600px; }
.admin-content { padding: 20px; overflow-y: auto; }
.admin-add { margin-bottom: 24px; }
.admin-add h4, .admin-list h4 { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 12px; }
.form-row { display: flex; gap: 8px; }
.form-row input { flex: 1; padding: 9px 12px; border: 1.5px solid #E2E8F0; border-radius: 7px; font-size: 13px; outline: none; }
.form-row input:focus { border-color: #2563EB; }

.account-list { display: flex; flex-direction: column; gap: 8px; }
.account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
}
.account-email { font-size: 13px; font-weight: 500; color: #1E293B; }
.account-actions { display: flex; gap: 6px; }
.account-actions button {
  padding: 5px 10px;
  border: 1px solid #E2E8F0;
  border-radius: 5px;
  background: white;
  font-size: 12px;
  cursor: pointer;
  color: #374151;
}
.account-actions .btn-del { color: #EF4444; border-color: #FECACA; }
.account-actions button:hover { background: #F1F5F9; }

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

/* ─── 반응형 ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .mail-list-panel { width: 280px; }
  .compose-box { width: 95vw; }
  .admin-box { width: 95vw; }
}
