/* ===== 테마 토큰 (M12-8 다크모드) =====
   라이트 = 기존 색상 그대로(회귀 없음). 다크는 :root[data-theme="dark"] 에서 변수만 덮어쓴다.
   테마는 클라이언트 localStorage('theme') 로 기기별 저장(환경설정 일반 탭에서 토글). */
:root {
  --bg: #ffffff;            /* 본문(앱) 배경 */
  --panel: #ffffff;         /* 카드/툴바/모달 */
  --panel-2: #fafafa;       /* 사이드바·미리보기 */
  --login-bg: #f0f2f5;
  --fg: #222222;            /* 기본 텍스트 */
  --fg-2: #555555;          /* 보조 텍스트(메타/라벨) */
  --muted: #888888;
  --border: #e3e3e3;
  --border-soft: #f0f0f0;
  --border-mid: #eeeeee;
  --border-input: #cccccc;
  --hover: #eef2fb;
  --hover-2: #f7f9fe;
  --hover-3: #f3f6fd;
  --accent: #2d6cdf;
  --accent-hover: #245ec0;
  --accent-fg: #ffffff;
  --accent-weak: #dde8fb;
  --btn: #f6f6f6;
  --btn-hover: #eeeeee;
  --chip-bg: #eef2fb;
  --chip-border: #d4e0f7;
  --star: #f1c40f;
  --notice-bg: #fff8e1;
  --notice-border: #f3e2a9;
  --notice-fg: #7a5b00;
  --shadow: rgba(0, 0, 0, .1);
}
:root[data-theme="dark"] {
  --bg: #15171c;
  --panel: #1e2128;
  --panel-2: #23272f;
  --login-bg: #15171c;
  --fg: #e6e8eb;
  --fg-2: #b6bcc6;
  --muted: #9aa1ac;
  --border: #3a3f49;
  --border-soft: #2c313a;
  --border-mid: #2c313a;
  --border-input: #474d58;
  --hover: #2a3140;
  --hover-2: #262c36;
  --hover-3: #283041;
  --accent: #4f8cf0;
  --accent-hover: #5f98f2;
  --accent-fg: #ffffff;
  --accent-weak: #2a3552;
  --btn: #2a2f38;
  --btn-hover: #333945;
  --chip-bg: #2a3552;
  --chip-border: #3b4a6b;
  --star: #f1c40f;
  --notice-bg: #3a3320;
  --notice-border: #5a4d2a;
  --notice-fg: #e8d28a;
  --shadow: rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", "Apple SD Gothic Neo", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
.muted { color: var(--muted); font-size: 13px; }
.error { color: #c0392b; margin-top: 8px; font-size: 13px; min-height: 16px; }

/* SYS-1623 mailbox-quota usage bar (계정관리 사용량) */
.quota-bar { width: 240px; max-width: 100%; height: 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin: 2px 0 4px; }
.quota-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.quota-fill.warn { background: #d9b23a; }
.quota-fill.over { background: #c0392b; }
button { cursor: pointer; border: 1px solid var(--border-input); background: var(--btn); color: var(--fg); border-radius: 4px; padding: 6px 10px; font-size: 13px; }
button:hover { background: var(--btn-hover); }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { background: var(--panel); color: var(--fg); }
a { color: var(--accent); }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--login-bg); }
.login-card { background: var(--panel); padding: 32px; border-radius: 8px; box-shadow: 0 2px 12px var(--shadow); width: 320px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.login-card input { padding: 8px; border: 1px solid var(--border-input); border-radius: 4px; font-size: 14px; }

/* shell */
.topbar { display: flex; align-items: center; gap: 12px; background: var(--accent); color: var(--accent-fg); padding: 8px 16px; }
.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; }
.topbar button { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.3); }
.search { display: flex; gap: 4px; }
.search input { padding: 5px 8px; border-radius: 4px; border: 1px solid var(--border-input); width: 200px; }
.search select { border-radius: 4px; border: 1px solid var(--border-input); }

/* SYS-1913: 복구 이메일 미등록 경고 배너(상단 전폭, 클릭 시 /register-recovery). 흰 글자/빨간 배경이라
   라이트·다크 테마 모두에서 동일하게 읽힌다. advPanel과 같이 헤더-레이아웃 사이 흐름에 위치. */
.recovery-banner { display: block; background: #b91c1c; color: #fff; text-decoration: none;
  text-align: center; padding: 10px 16px; font-size: 13px; font-weight: 600; }
.recovery-banner:hover { background: #a01818; }
.recovery-banner u { text-underline-offset: 2px; }

/* SYS-2130: 컴포즈 외부발신 경고 배너(수신자 필드 아래). 앰버 톤 — 차단이 아닌 주의 환기. 라이트/다크 공통 가독. */
.ext-warn { margin: 4px 0; padding: 7px 10px; border-radius: 6px; font-size: 13px; line-height: 1.4;
  background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

.layout { display: flex; height: calc(100vh - 41px); }
.sidebar { width: 220px; border-right: 1px solid var(--border); padding: 12px; overflow-y: auto; background: var(--panel-2); }
.sidebar .primary { width: 100%; margin-bottom: 12px; }
.mailboxes { display: flex; flex-direction: column; gap: 2px; }
.mbx { display: flex; justify-content: space-between; align-items: center; padding: 7px 8px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.mbx:hover { background: var(--hover); }
.mbx.active { background: var(--accent-weak); font-weight: 600; }
.mbx .count { color: var(--accent); font-size: 12px; }
.mbx-actions { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 4px; }
.mbx-actions button { font-size: 12px; flex: 1; }

/* SYS-1658 멀티 계정 워크스페이스 — 사이드바 계정 스위처 */
.acct-nav { margin-bottom: 6px; }
.acct .acct-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.acct-dot.st-ok { background: #2e9e5b; }
.acct-dot.st-err { background: #d64545; }
.acct-dot.st-off { background: #999; }

.content { flex: 1; overflow-y: auto; background: var(--bg); position: relative; }
.toolbar, .msg-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border-mid); position: sticky; top: 0; background: var(--panel); flex-wrap: wrap; }
.mbx-title { font-weight: 600; margin-left: 8px; }
.pager { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.list-limit { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); margin-right: 4px; }
.list-limit select { font-size: 12px; padding: 1px 4px; }
#unseenToggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.msglist { width: 100%; border-collapse: collapse; }
.msglist tr { border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.msglist tr:hover { background: var(--hover-2); }
.msglist tr.unseen { font-weight: 700; }
.msglist td { padding: 8px 10px; font-size: var(--list-font, 13px); vertical-align: middle; } /* SYS-1698 목록 글자 크기 */
.msglist td.col-from { width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.msglist td.col-date { width: 150px; color: var(--muted); white-space: nowrap; text-align: right; }
.msglist td.col-flag { width: 24px; text-align: center; }
.msglist .star { color: var(--border-input); }
.msglist .star.on { color: var(--star); }
.msglist .attach-ic { color: var(--muted); }

.msg-head { padding: 12px 16px; border-bottom: 1px solid var(--border-mid); }
.msg-head .subject { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.msg-head .meta { font-size: 13px; color: var(--fg-2); line-height: 1.6; }
.msg-attach { padding: 8px 16px; font-size: 13px; }
.msg-attach a { margin-right: 12px; }
.msg-body { width: 100%; height: 60vh; border: none; background: #fff; }
/* SYS-1647 수신확인 */
.receipt-opt { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; margin-left: 4px; white-space: nowrap; }
.msglist .receipt-badge { color: var(--muted); font-size: 12px; margin-left: 6px; white-space: nowrap; }
.msglist .receipt-badge.all-read { color: #2da44e; }
.msg-receipt { padding: 8px 16px; border-bottom: 1px solid var(--border-mid); font-size: 13px; }
.msg-receipt .receipt-title { font-weight: 600; margin-bottom: 4px; }
.msg-receipt .receipt-table { border-collapse: collapse; }
.msg-receipt .receipt-table td { padding: 2px 14px 2px 0; }
.msg-receipt .r-read { color: #2da44e; }
.msg-receipt .r-unread { color: var(--muted); }
.msg-receipt .r-ext { color: #bf8700; }
.msg-receipt .receipt-note { color: var(--muted); font-size: 12px; margin-top: 6px; }
/* SYS-1648 메일 회수 */
.msglist .recall-badge { color: var(--muted); font-size: 12px; margin-left: 6px; white-space: nowrap; }
.msglist .recall-badge.recalled { color: #2da44e; }
.msg-recall { padding: 8px 16px; border-bottom: 1px solid var(--border-mid); font-size: 13px; }
.msg-recall .recall-title { font-weight: 600; margin-bottom: 4px; }
.msg-recall .recall-table { border-collapse: collapse; }
.msg-recall .recall-table td { padding: 2px 14px 2px 0; }
.msg-recall .r-recall { color: #2da44e; }
.msg-recall .r-blocked { color: var(--muted); }
.msg-recall .r-ext { color: #bf8700; }
.msg-recall .recall-note { color: var(--muted); font-size: 12px; margin-top: 6px; }
.msg-toolbar button[data-act="msgRecall"] { color: #b35900; }
.msg-toolbar button[data-act="msgRecall"]:disabled { color: var(--muted); cursor: default; }

/* SYS-1649 예약발송 */
.schedule-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 14px; border-top: 1px solid var(--border-soft); }
.schedule-row #cSchedule { border: 1px solid var(--border-input); border-radius: 4px; padding: 4px 6px; font-size: 13px; background: var(--panel); color: var(--fg); }
.schedule-note { flex-basis: 100%; color: var(--muted); font-size: 12px; line-height: 1.5; }
.msglist .sched-badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; white-space: nowrap; border: 1px solid var(--border); color: var(--fg-2); }
.msglist .sched-badge.sb-sched { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
.msglist .sched-badge.sb-sending { color: #bf8700; border-color: #d9b23a; }
.msglist .sched-badge.sb-failed { color: #c0392b; border-color: #e0a39c; }
.msglist .sched-badge.sb-sent { color: #2da44e; border-color: #9bd6ac; }
.msglist .sched-badge.sb-cancel { color: var(--muted); }
.msglist td.sched-actions { width: 130px; white-space: nowrap; text-align: right; }
.sched-err { color: #c0392b; font-size: 12px; margin-left: 6px; cursor: help; }

/* compose modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: var(--panel); width: 640px; max-width: 95vw; max-height: 90vh; border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; background: var(--accent); color: var(--accent-fg); padding: 10px 14px; font-weight: 600; }
.modal-head button { background: transparent; color: #fff; border: none; font-size: 20px; }
.modal-card label { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 13px; border-bottom: 1px solid var(--border-soft); }
.modal-card label input { flex: 1; border: none; padding: 4px; font-size: 14px; outline: none; background: transparent; color: var(--fg); }
.compose-body { min-height: 200px; padding: 12px 14px; font-size: 14px; outline: none; overflow-y: auto; color: var(--fg); }
.compose-body .sig { color: var(--fg-2); }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border-mid); }

/* 발송 전 미리보기 컨펌 (SYS-1701) — 기존 .modal/.modal-card 재사용 */
.preview-pad .pv-row { display: flex; gap: 8px; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--border-soft); }
.preview-pad .pv-label { flex: 0 0 64px; color: var(--muted); }
.preview-pad .pv-val { flex: 1; word-break: break-all; color: var(--fg); }
.preview-frame { width: 100%; height: 320px; margin-top: 10px; border: 1px solid var(--border-mid); border-radius: 6px; background: #fff; }

/* ===== M12-9 읽기 배치: 하단 리딩 패널 / 모달 (기본 스왑은 JS display 토글) ===== */
/* 리딩 패널(bodyPreview): 목록(위) + 본문(아래) 세로 분할. 메시지가 열렸을 때만 분할. */
.content.read-pane.msg-open { display: flex; flex-direction: column; overflow: hidden; height: 100%; }
.content.read-pane.msg-open #listView { flex: 1 1 45%; overflow-y: auto; min-height: 0; }
.content.read-pane.msg-open #msgView { flex: 1 1 55%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; border-top: 3px solid var(--border-mid); }
.content.read-pane.msg-open #msgView .msg-body { flex: 1 1 auto; height: auto; min-height: 160px; }
.content.read-pane .msg-toolbar [data-act="back"] { display: none; }   /* 목록이 늘 보이므로 '뒤로' 불필요 */

/* 읽기 모달(openReadInNewWindow): 본문을 가운데 카드로 띄우고 목록은 뒤에 유지 */
.content.read-modal.msg-open::before { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
.content.read-modal.msg-open #msgView { position: fixed; top: 5vh; left: 50%; transform: translateX(-50%); width: 820px; max-width: 92vw; height: 88vh; z-index: 41; background: var(--panel); border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; }
.content.read-modal.msg-open #msgView .msg-body { flex: 1 1 auto; height: auto; min-height: 160px; }

/* 인라인 작성(openComposeInNewWindow=false): compose 가 콘텐츠 영역을 채움(배경 오버레이 없음) */
.modal.inline { position: absolute; inset: 0; background: var(--bg); display: block; z-index: 30; }
.modal.inline .modal-card { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; }

/* M6 — received attachments */
.msg-attach .att-item { margin-right: 14px; white-space: nowrap; }
.msg-attach .att-prev { font-size: 12px; }

/* M6 — compose attachments */
.attach-area { border-top: 1px solid var(--border-soft); padding: 8px 14px; }
.attach-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--chip-bg); border: 1px solid var(--chip-border); border-radius: 14px; padding: 3px 6px 3px 10px; font-size: 12px; }
.chip-x { border: none; background: transparent; padding: 0 4px; font-size: 14px; line-height: 1; color: var(--muted); }
.chip-x:hover { background: transparent; color: #c0392b; }

/* M6 — contacts */
.contacts-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.contacts-table th, .contacts-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft); text-align: left; }
.contacts-table .ct-actions { white-space: nowrap; }
/* SYS-1946: 주소록 모달 소제목(개인/전사) + 전사 읽기전용 태그. */
.contacts-sub { margin: 12px 14px 2px; font-size: 12px; font-weight: 600; color: var(--fg-2); }
.contacts-sub .contacts-ro { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 6px; }
/* 행 액션을 아이콘 버튼으로(메일 추가 / 수정 / 삭제). 조직도 .recip-add 와 동일 톤. */
.contacts-table .ct-actions button { padding: .3rem; margin-left: 4px; line-height: 0; border-radius: 6px; color: var(--fg-2); vertical-align: middle; }
.contacts-table .ct-actions button:hover { border-color: var(--accent); color: var(--accent); }
.contacts-table .ct-actions button.danger:hover { border-color: #c0392b; color: #c0392b; }
.contacts-table .ct-actions button svg { width: 16px; height: 16px; display: block; }
.contact-form { display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border-mid); flex-wrap: wrap; }
.contact-form input { flex: 1; min-width: 120px; padding: 6px; border: 1px solid var(--border-input); border-radius: 4px; font-size: 13px; }

/* M6 — undo send banner */
.undo-bar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #323232; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.3); display: flex; align-items: center; gap: 14px; z-index: 80; font-size: 14px; }
.undo-bar button { background: transparent; color: #6db3ff; border: none; font-weight: 600; }
.undo-bar button:hover { background: transparent; text-decoration: underline; }

/* M7 — external client connection info */
#connInfoModal p.muted { margin: 8px 14px; }
.conn-table { border-collapse: collapse; width: calc(100% - 28px); margin: 0 14px; font-size: 13px; }
.conn-table th, .conn-table td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; }
.conn-table thead th { background: var(--panel-2); }
.conn-table tbody th { background: var(--panel-2); width: 110px; white-space: nowrap; }
.rec { color: #15803d; font-weight: 600; }

/* ===== 사용자 환경설정 페이지 (/settings, 탭) ===== */
.settings-wrap { max-width: 880px; margin: 0 auto; padding: 20px 16px 64px; }
.settings-title { font-size: 22px; margin: 8px 0 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.tab { background: transparent; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; padding: 10px 14px; font-size: 14px; color: var(--fg-2); border-radius: 0; }
.tab:hover { background: var(--hover-3); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.set-section { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin: 0 0 16px; background: var(--panel); }
.set-section h3 { margin: 0 0 12px; font-size: 15px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-head h3 { margin: 0; }
.set-section .kv { width: 100%; border-collapse: collapse; }
.set-section .kv th { text-align: left; width: 120px; padding: 7px 8px; color: var(--fg-2); font-weight: 600; font-size: 13px; vertical-align: middle; white-space: nowrap; }
.set-section .kv td { padding: 7px 8px; font-size: 13px; }
.set-section .kv input { padding: 6px; border: 1px solid var(--border-input); border-radius: 4px; font-size: 13px; }
/* 라디오 그룹 fieldset (IMAP/POP 탭, 스팸 차단 동작) */
.settings-group { border: 1px solid var(--border); border-radius: 6px; padding: 4px 12px 10px; }
.settings-group legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.set-q { font-size: 13px; font-weight: 600; color: var(--fg); margin: 10px 0 4px; }
label.set-opt { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: none; font-size: 13px; cursor: pointer; color: var(--fg-2); }
label.set-opt input { flex: 0 0 auto; width: auto; }
.form-rows { display: flex; flex-direction: column; gap: 10px; max-width: 440px; }
.form-rows > label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--fg-2); }
.form-rows input, .form-rows textarea { padding: 7px; border: 1px solid var(--border-input); border-radius: 4px; font-size: 13px; font-family: inherit; }
label.inline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-2); margin: 8px 0; }
label.inline input[type=checkbox] { flex: 0 0 auto; }   /* 모달 .modal-card label input{flex:1}이 체크박스를 늘려 라벨 간격이 벌어지던 것 교정 */
label.inline input[type=number] { width: 90px; padding: 5px; border: 1px solid var(--border-input); border-radius: 4px; }
label.inline select { padding: 5px; border: 1px solid var(--border-input); border-radius: 4px; }
.set-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
/* 서브 섹션(일반 탭 기본환경/읽기/쓰기, 스팸 탭 스팸/수신거부) */
.sub-head { font-weight: 700; font-size: 13px; color: var(--fg); margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border-mid); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-section > .sub-head:first-child { margin-top: 0; }
/* 옵션 행(라벨 + 컨트롤 + 안내/배지 인라인) */
.opt-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-2); margin: 9px 0; flex-wrap: wrap; }
.opt-row select { padding: 5px 6px; border: 1px solid var(--border-input); border-radius: 4px; font-size: 13px; }
.opt-row input[type=number] { width: 90px; padding: 5px 6px; border: 1px solid var(--border-input); border-radius: 4px; font-size: 13px; }
.opt-row input[type=checkbox] { flex: 0 0 auto; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid-table th, .grid-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); text-align: left; }
.grid-table th.num, .grid-table td.num { text-align: right; width: 72px; }
.grid-table .empty, .grid-table td.empty { text-align: center; color: var(--muted); padding: 18px; }
.grid-table .row-actions { text-align: right; white-space: nowrap; }
button.mini { font-size: 11px; padding: 3px 8px; margin-left: 4px; }
.add-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.add-row input { flex: 1; min-width: 200px; padding: 7px; border: 1px solid var(--border-input); border-radius: 4px; font-size: 13px; }
.notice { background: var(--notice-bg); border: 1px solid var(--notice-border); color: var(--notice-fg); border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.todo-badge { display: inline-block; background: var(--chip-bg); color: var(--accent); border: 1px solid var(--chip-border); border-radius: 12px; padding: 2px 8px; font-size: 11px; white-space: nowrap; font-weight: 600; }
/* M25-3(SYS-1997): 서명 탭 에디터(Jodit)와 아래 옵션·미리보기가 바짝 붙어 겹쳐 보이던 문제 — 여백 확대(설정 탭 한정). */
#panel-signature .jodit-container { margin-bottom: 14px; }
.sig-prev-wrap { margin-top: 24px; }

/* M25-4(SYS-1998): 리마인드 프리셋 폼 — 요일 토글 배치. */
.preset-form { margin-top: 10px; }
.preset-days { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.preset-day { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; }
.preset-day input[type=checkbox] { flex: 0 0 auto; }
.sig-preview { border: 1px dashed var(--border-input); border-radius: 6px; padding: 10px; min-height: 40px; font-size: 13px; color: var(--fg-2); background: var(--panel-2); }
#sigText { width: 100%; border: 1px solid var(--border-input); border-radius: 4px; padding: 8px; font-size: 13px; font-family: inherit; }

/* 자동 분류 — 규칙 편집기 모달 (기존 .modal/.modal-card 재사용) */
.modal-pad { padding: 12px 14px; overflow-y: auto; }
.modal-pad label { padding: 0; border-bottom: none; }
label.block { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--fg-2); margin-bottom: 10px; }
label.block input { padding: 7px; border: 1px solid var(--border-input); border-radius: 4px; font-size: 13px; }
.cond-head, .act-head { font-size: 13px; color: var(--fg-2); margin: 10px 0 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cond-list { display: flex; flex-direction: column; gap: 6px; }
.cond-row { display: flex; gap: 6px; align-items: center; }
.cond-row select, .cond-row input, .act-row select, .act-row input { padding: 6px; border: 1px solid var(--border-input); border-radius: 4px; font-size: 13px; }
.cond-row .cond-val { flex: 1; }
.act-row { display: flex; gap: 6px; margin-bottom: 8px; }
.act-row input { flex: 1; }

/* 받는사람 인라인 자동완성(주소록 typeahead, SYS-1643) — 테마 변수 사용 */
.addr-field { position: relative; }
.typeahead {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  margin: 2px 0 0; padding: 4px 0; list-style: none;
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 4px 14px var(--shadow); max-height: 240px; overflow-y: auto;
}
.typeahead li { padding: 6px 10px; cursor: pointer; font-size: 13px; }
.typeahead li .ta-name { font-weight: 600; }
.typeahead li .ta-email { color: var(--muted); margin-left: 6px; }
.typeahead li.active, .typeahead li:hover { background: var(--hover); }

/* ---------- 라벨/태그 (SYS-1650) ---------- */
/* colored label chip (list rows + read view); white text on the label color for contrast */
.label-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; line-height: 1.5; padding: 1px 8px; border-radius: 10px;
  color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); white-space: nowrap; vertical-align: middle;
}
.label-chip-x { cursor: pointer; font-weight: 700; opacity: .85; }
.label-chip-x:hover { opacity: 1; }
.label-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
/* sidebar */
.mbx-group-head { margin: 12px 4px 2px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mbx.label-nav { gap: 8px; justify-content: flex-start; }
/* read-view label bar */
.msg-labels { padding: 6px 16px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--border); }
.msg-labels-label { font-size: 12px; color: var(--muted); }
/* SYS-1943 Phase 2: 공유 메일함 협업 패널(담당자·상태·코멘트) + 목록 상태 배지 */
.msg-collab { padding: 8px 16px; border-bottom: 1px solid var(--border-mid); font-size: 13px; }
.msg-collab .collab-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.msg-collab .collab-lbl { color: var(--muted); font-size: 12px; }
.msg-collab select { font-size: 13px; padding: 2px 4px; }
.msg-collab .collab-comments { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.msg-collab .collab-c { background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: 6px; padding: 6px 8px; }
.msg-collab .collab-cauthor { font-weight: 600; }
.msg-collab .collab-cbody { margin-top: 2px; white-space: pre-wrap; }
.msg-collab .collab-cdel { font-size: 11px; margin-left: 6px; }
.msg-collab .collab-add { display: flex; gap: 6px; }
.msg-collab .collab-add input { flex: 1; padding: 4px 8px; }
.collab-chip { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--accent-weak); color: var(--fg-2); vertical-align: middle; }
.collab-chip.s-new { background: var(--border); color: var(--fg-2); }
.collab-chip.s-in_progress { background: #dce9fb; color: #1d4ed8; }
.collab-chip.s-done { background: #d7f0dd; color: #1a7f37; }
.collab-chip.s-held { background: #fbeecb; color: #9a6700; }
/* label picker popover (built in JS, appended to body) */
.label-menu {
  position: absolute; z-index: 60; min-width: 180px; max-height: 300px; overflow-y: auto;
  background: var(--panel); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 4px 14px var(--shadow); padding: 4px 0;
}
.label-menu-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; cursor: pointer; font-size: 13px; }
.label-menu-item:hover { background: var(--hover); }
.label-menu-item.on { font-weight: 600; }
.label-menu-item .label-mark { width: 12px; color: var(--accent); font-weight: 700; }

/* SYS-1624 advanced search (상세검색) panel + result folder chip */
.adv-panel { background: var(--panel); color: var(--fg); border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 10px var(--shadow); padding: 10px 16px; display: flex; flex-wrap: wrap;
  gap: 10px 18px; align-items: flex-end; }
.adv-row { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.adv-row.chk { flex-direction: row; align-items: center; gap: 6px; }
.adv-row > label { opacity: .75; }
.adv-panel input, .adv-panel select { padding: 4px 7px; border-radius: 4px;
  border: 1px solid var(--border-input); background: var(--panel); color: var(--fg); }
.adv-panel input[type=number] { width: 90px; }
.adv-panel .dates { display: flex; align-items: center; gap: 6px; }
.adv-actions { display: flex; gap: 6px; }
.rowbox-chip { display: inline-block; font-size: 11px; opacity: .7; border: 1px solid var(--border);
  border-radius: 3px; padding: 0 5px; margin-left: 6px; vertical-align: middle; }

/* 조직도(SYS-2128) — 그룹 태그 선택 → 그룹 트리 + 구성원, 대표 서열 배지. 테마 토큰 사용(라이트/다크 자동). */
#orgModal .modal-card { height: 80vh; }   /* #1 태그·구성원 수와 무관하게 일정한 크기(남는 하단 여백 허용) */
.org-toolbar { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .8rem 18px .6rem; }  /* #2 가장자리 여백 */
.org-tree { flex: 1; min-height: 0; overflow-y: auto; padding: 0 18px 16px; }   /* #1 남는 공간을 채워 크기 고정 + #2 여백 */
/* #3 커스텀 태그 셀렉터 (div 기반 가짜 select) */
.org-select { position: relative; display: inline-flex; align-items: center; gap: .5rem; }
.org-select-label { font-size: .85rem; color: var(--muted); }
.org-select-trigger { display: inline-flex; align-items: center; justify-content: space-between; gap: .6rem; min-width: 160px;
  padding: .42rem .7rem; border: 1px solid var(--border-input); border-radius: 8px; background: var(--panel); color: var(--fg); font-size: .88rem; }
.org-select-trigger:hover { border-color: var(--accent); background: var(--panel); }  /* 전역 button:hover 회색 배경 상쇄(테두리로만 hover 표시) */
.org-select-trigger[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.org-select-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-select-caret { font-size: .65rem; color: var(--muted); transition: transform .15s ease; }
.org-select-trigger[aria-expanded="true"] .org-select-caret { transform: rotate(180deg); }
.org-select-menu { position: absolute; top: calc(100% + 5px); left: 0; z-index: 60; min-width: 100%;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px var(--shadow);
  padding: .3rem; max-height: 320px; overflow-y: auto; }
.org-select-menu[hidden] { display: none; }
.org-select-option { display: flex; align-items: center; justify-content: space-between; gap: 1rem; white-space: nowrap;
  padding: .45rem .6rem; border-radius: 6px; cursor: pointer; font-size: .88rem; color: var(--fg); }
.org-select-option:hover { background: var(--hover-2); }
.org-select-option[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.org-select-option[aria-selected="true"]::after { content: '✓'; font-size: .82rem; }
/* 그룹·조직원 검색 — 툴바 우측 정렬(margin-left:auto) */
.org-search { margin-left: auto; width: 220px; max-width: 50%; padding: .42rem .7rem; border: 1px solid var(--border-input); border-radius: 8px; background: var(--panel); color: var(--fg); font-size: .88rem; }
.org-search::placeholder { color: var(--muted); }
.org-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.org-dept { margin: .3rem 0; }
/* #4 접기 가능한 그룹 헤더 */
.org-dept-name { display: flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--fg); padding: .35rem 0; border-bottom: 1px solid var(--border-soft); }
.org-dept-name.collapsible { cursor: pointer; user-select: none; }
.org-dept-caret { flex: none; width: .8rem; text-align: center; font-size: .7rem; color: var(--muted); }
.org-dept.collapsed > .org-dept-body { display: none; }   /* 접으면 직할 구성원 + 하위 그룹 서브트리 통째로 숨김 */
.org-person { display: flex; align-items: center; gap: .4rem; padding: .25rem 0 .25rem .9rem; }
.org-person:hover { background: var(--hover-2); }
.org-person-info { display: flex; align-items: baseline; gap: .5rem; flex: 1; min-width: 0; }
.org-name { color: var(--fg); }
.org-rank { font-size: .78rem; color: var(--accent); background: var(--chip-bg); border: 1px solid var(--chip-border); border-radius: 4px; padding: 0 .3rem; white-space: nowrap; }
.org-email { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-person button { font-size: .8rem; padding: .15rem .5rem; }
/* SYS-1946 #3: 받는사람 추가 To/Cc/Bcc 3버튼(텍스트) — 조직도·개인/전사 주소록 공용. 아이콘 톤(padding/line-height:0)을
   충분한 스코프(.org-person button / .ct-actions button 를 이김)로 덮어써 작은 텍스트 버튼으로 만든다. */
.recip-add-grp { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 4px; }
.org-person .recip-add-grp .recip-add,
.contacts-table .ct-actions .recip-add { padding: .1rem .38rem; line-height: 1.5; font-size: .72rem; border-radius: 5px; color: var(--fg-2); background: none; }
.org-person .recip-add-grp .recip-add:hover,
.contacts-table .ct-actions .recip-add:hover { border-color: var(--accent); color: var(--accent); }
/* 이미 수신자로 추가된 주소 → 3버튼 모두 '추가됨'(비활성·muted). 각 hover 및 전역 button:hover 배경을 이기도록 스코프+.added. */
.org-person .recip-add-grp .recip-add.added,
.org-person .recip-add-grp .recip-add.added:hover,
.contacts-table .ct-actions .recip-add.added,
.contacts-table .ct-actions .recip-add.added:hover { color: var(--muted); border-color: transparent; background: none; cursor: default; }

/* 내 상태 셀렉터(SYS-2061) + 조직도 상태 배지 */
.status-sel { padding: .2rem .4rem; border: 1px solid var(--border-input); border-radius: 6px; background: var(--panel); color: var(--fg); font: inherit; font-size: .85rem; }
.org-presence { font-size: .8rem; color: var(--fg-2); white-space: nowrap; }
