* { 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; }

/* ─── WhereCrew 발송 스튜디오 ───────────────────────────────── */
.compose-modal { padding: 24px; background: rgba(15, 23, 42, 0.64); }
.compose-box {
  width: min(960px, 96vw);
  max-height: min(900px, 94vh);
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.34);
}
.compose-box form { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.compose-studio-header {
  padding: 20px 26px 18px;
  color: white;
  background: linear-gradient(120deg, #0F2B57 0%, #1D4ED8 56%, #2563EB 100%);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.compose-kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; color: #BFDBFE; }
.compose-studio-header h3 { margin: 5px 0 2px; color: white; font-size: 21px; font-weight: 700; }
.compose-status { margin: 0; font-size: 13px; color: #DBEAFE; }
.compose-close { color: #DBEAFE; border: 1px solid rgba(255,255,255,0.26); padding: 7px; }
.compose-close:hover { color: white; background: rgba(255,255,255,0.14); }

.compose-fields { padding: 8px 26px 0; }
.compose-field { display: flex; align-items: center; gap: 16px; min-height: 51px; border-bottom: 1px solid #EAF0F7; }
.compose-field label { font-size: 13px; font-weight: 700; color: #475569; min-width: 88px; }
.compose-field input { flex: 1; min-width: 0; border: none; outline: none; font-size: 14px; color: #0F172A; padding: 12px 0; background: transparent; }
.compose-field input::placeholder { color: #94A3B8; }
.compose-sender-row { background: #F8FAFC; margin: 0 -26px; padding: 0 26px; }
.sender-identity { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #334155; font-weight: 600; }
.sender-dot { width: 8px; height: 8px; border-radius: 50%; background: #22C55E; box-shadow: 0 0 0 3px #DCFCE7; }
.recipient-control { flex: 1; display: flex; align-items: center; min-width: 0; }
.recipient-control input { width: 100%; }
.recipient-toggle {
  flex-shrink: 0; border: none; color: #2563EB; background: #EFF6FF; font-size: 12px; font-weight: 700;
  border-radius: 6px; padding: 6px 8px; cursor: pointer;
}
.recipient-toggle:hover { background: #DBEAFE; }
.optional-recipient { background: #FAFCFF; margin: 0 -10px; padding: 0 10px; }
.compose-subject-row input { font-size: 15px; font-weight: 600; }

.compose-toolbar {
  padding: 10px 26px;
  border-bottom: 1px solid #E2E8F0;
  background: #F8FAFC;
  display: flex;
  align-items: center;
  gap: 6px;
}
.toolbar-btn, .toolbar-text-btn {
  min-width: 32px; border: 1px solid #D9E2EF; border-radius: 6px; background: white; cursor: pointer;
  font-size: 13px; color: #334155; min-height: 30px; padding: 4px 9px;
}
.toolbar-text-btn { font-size: 12px; font-weight: 600; }
.toolbar-btn:hover, .toolbar-text-btn:hover { border-color: #93C5FD; color: #1D4ED8; background: #EFF6FF; }
.toolbar-divider { width: 1px; height: 22px; background: #D7E0EB; margin: 0 3px; }

.compose-body {
  flex: 1;
  min-height: 260px;
  padding: 22px 26px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.8;
  outline: none;
  color: #1E293B;
}
.compose-body:empty::before { content: attr(placeholder); color: #94A3B8; }
.compose-body hr { border: 0; border-top: 1px solid #CBD5E1; margin: 18px 0; }

.compose-assets { margin: 0 26px 16px; padding: 16px 18px; border: 1px solid #DCE6F2; border-radius: 12px; background: #FBFDFF; }
.compose-assets-topline { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.compose-assets h4 { margin: 0; font-size: 13px; color: #1E3A5F; }
.compose-assets p { margin: 4px 0 0; font-size: 12px; color: #64748B; }
.compose-asset-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.attach-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; font-size: 12px; font-weight: 700;
  color: #334155; cursor: pointer; padding: 6px 10px; border-radius: 7px; border: 1px solid #CBD5E1; background: white;
}
.attach-btn:hover { border-color: #60A5FA; background: #EFF6FF; color: #1D4ED8; }
.attach-link-btn { color: #1D4ED8; border-color: #BFDBFE; }
.large-link-policy { margin-top: 13px; padding: 11px 12px; background: #F0F9FF; border: 1px solid #BAE6FD; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; color: #0C4A6E; }
.large-link-policy > div { display: flex; flex-direction: column; gap: 3px; }
.large-link-policy strong { color: #075985; }
.large-link-policy span { color: #475569; line-height: 1.45; }
.large-link-policy label { display: flex; align-items: center; gap: 7px; white-space: nowrap; font-weight: 700; }
.large-link-policy select { border: 1px solid #7DD3FC; border-radius: 6px; padding: 5px 7px; color: #0C4A6E; background: white; font: inherit; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.attachment-empty { color: #94A3B8; font-size: 12px; }
.attachment-warning {
  flex-basis: 100%;
  padding: 8px 10px;
  border: 1px solid #FCD34D;
  border-radius: 7px;
  background: #FFFBEB;
  color: #92400E;
  font-size: 12px;
  line-height: 1.5;
}
.attach-tag {
  background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: 6px; padding: 5px 8px; font-size: 12px;
  color: #1D4ED8; display: inline-flex; align-items: center; gap: 4px;
}
.attach-tag button { background: none; border: none; cursor: pointer; color: #64748B; font-size: 14px; line-height: 1; }
.signature-tag { background: #F5F3FF; border-color: #DDD6FE; color: #6D28D9; }

/* ─── 서명 및 첨부 미리보기 ─────────────────────────────────── */
.signature-box { width: min(720px, calc(100vw - 30px)); max-height: min(86vh, 820px); overflow-y: auto; }
.signature-box .modal-header { position: sticky; top: 0; z-index: 1; background: white; padding: 20px 24px 14px; border-bottom: 1px solid #E2E8F0; }
.signature-box form { padding: 18px 24px 24px; }
.signature-box textarea { width: 100%; min-height: 130px; resize: vertical; border: 1px solid #CBD5E1; border-radius: 8px; padding: 10px; font: 14px/1.55 inherit; color: #1E293B; outline: none; }
.signature-box textarea:focus { border-color: #60A5FA; box-shadow: 0 0 0 3px #DBEAFE; }
.signature-box input[type=file] { border: none; padding: 10px 0; }
.field-hint { margin: 6px 0 0; color: #64748B; font-size: 12px; line-height: 1.5; }
.signature-file-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.signature-section-label { grid-column: 1 / -1; font-size: 12px; color: #475569; font-weight: 700; margin-top: 4px; }
.signature-file-card { overflow: hidden; border: 1px solid #DCE6F2; border-radius: 9px; background: #FAFCFF; min-height: 122px; display: flex; flex-direction: column; }
.signature-preview-image { width: 100%; height: 104px; object-fit: contain; background: #F1F5F9; }
.signature-preview-pdf { width: 100%; height: 110px; border: none; background: #F1F5F9; }
.signature-preview-file-icon { height: 84px; display: grid; place-items: center; font-size: 30px; background: #F1F5F9; }
.signature-file-meta { display: flex; flex-direction: column; gap: 3px; padding: 8px; font-size: 11px; color: #64748B; }
.signature-file-meta strong { color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-sm-danger { align-self: flex-start; margin-top: 3px; padding: 3px 7px; border: 1px solid #FECACA; border-radius: 5px; background: #FFF1F2; color: #BE123C; font-size: 11px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@media (max-width: 640px) { .large-link-policy { align-items: flex-start; flex-direction: column; } .large-link-policy label { white-space: normal; } .signature-file-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.compose-footer {
  padding: 15px 26px; border-top: 1px solid #E2E8F0; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: white;
}
.compose-summary { font-size: 12px; color: #64748B; }
.compose-actions { display: flex; align-items: center; gap: 6px; }
.compose-actions .btn-secondary { margin-right: 0; }
.compose-send-btn { min-width: 116px; min-height: 40px; font-weight: 700; }
.compose-error { margin: 0 26px 18px; }

/* ─── 계정 관리 ──────────────────────────────────────────── */
.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-modal { padding: 8px; }
  .compose-box { width: 100%; max-height: 98vh; border-radius: 12px; }
  .compose-studio-header { padding: 16px 18px; }
  .compose-studio-header h3 { font-size: 18px; }
  .compose-fields { padding: 6px 18px 0; }
  .compose-field { gap: 10px; }
  .compose-field label { min-width: 72px; font-size: 12px; }
  .compose-sender-row { margin: 0 -18px; padding: 0 18px; }
  .compose-toolbar { padding: 8px 18px; overflow-x: auto; }
  .compose-body { min-height: 210px; padding: 18px; }
  .compose-assets { margin: 0 18px 12px; padding: 14px; }
  .compose-assets-topline { align-items: flex-start; flex-direction: column; }
  .compose-asset-actions { justify-content: flex-start; }
  .compose-footer { padding: 13px 18px; align-items: flex-end; flex-direction: column; }
  .compose-actions { width: 100%; justify-content: flex-end; }
  .compose-error { margin: 0 18px 14px; }
  .admin-box { width: 95vw; }
}
