/* KPIE Webmail */
:root {
  --bg: #f4f6f9; --panel: #fff; --line: #e3e7ee; --text: #1f2933; --muted: #7b8794;
  --primary: #1f6feb; --primary-d: #1859c4; --danger: #d64545; --warn: #e8a317; --ok: #2f9e44;
  --side: 220px; --top: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 20px; margin: 0 0 14px; }
h2 small { font-size: 13px; color: var(--muted); font-weight: normal; margin-left: 8px; }
h3 { font-size: 16px; margin: 20px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.inline { display: inline; }
.ellipsis { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }

input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], select, textarea {
  font: inherit; padding: 7px 9px; border: 1px solid #cfd6df; border-radius: 6px; background: #fff; color: var(--text); max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,111,235,.25); border-color: var(--primary); }
label { display: block; margin: 0 0 12px; }
label > input[type=text], label > input[type=password], label > input[type=number], label > input[type=date], label > select { display: block; width: 100%; margin-top: 4px; }
label.chk { display: inline-flex; align-items: center; gap: 6px; margin: 0 12px 0 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0 0 14px; }

.btn { display: inline-block; font: inherit; padding: 7px 14px; border: 1px solid #cfd6df; border-radius: 6px; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: #f0f3f7; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { color: var(--danger); border-color: #f0c4c4; }
.btn-danger:hover { background: #fdf0f0; }
.btn-block { display: block; width: 100%; padding: 11px; font-size: 15px; }

/* layout */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--top); background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 16px; z-index: 20; }
.logo { font-size: 18px; font-weight: bold; color: var(--text); white-space: nowrap; }
.logo-icon { color: var(--primary); }
.topsearch { flex: 1; max-width: 480px; }
.topsearch input { width: 100%; border-radius: 20px; background: #f4f6f9; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.uname { font-weight: bold; }
.session-timer { font-size: 12px; color: var(--muted); }
.session-timer.soon { color: var(--danger); font-weight: bold; }
.menu-toggle { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; }
.wrap { display: flex; padding-top: var(--top); min-height: 100%; }
.sidebar { width: var(--side); flex: 0 0 var(--side); background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; position: fixed; top: var(--top); bottom: 0; overflow-y: auto; }
.content { flex: 1; margin-left: var(--side); padding: 20px 24px 60px; min-width: 0; }
.btn-compose { display: block; text-align: center; padding: 11px; font-size: 15px; font-weight: bold; margin-bottom: 6px; }
.btn-self { display: block; text-align: center; margin-bottom: 14px; }
.folders { border-top: 1px solid var(--line); padding: 8px 0; }
.folder { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.folder:hover { background: #f0f3f7; text-decoration: none; }
.folder.active { background: #e8f0fe; color: var(--primary); font-weight: bold; }
.folder.user-folder span:first-child::before { content: "📁 "; font-size: 12px; }
.badge { background: var(--primary); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.count { color: var(--muted); font-size: 12px; }
.quota { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.quota-bar { height: 6px; background: #e9edf2; border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.quota-bar span { display: block; height: 100%; background: var(--primary); }
.quota-bar span.danger { background: var(--danger); }

/* alerts */
.alert { padding: 10px 14px; border-radius: 6px; margin: 0 0 12px; border: 1px solid; }
.alert-ok { background: #ebfbee; border-color: #b2f2bb; color: #1b5e20; }
.alert-error, .alert-danger { background: #fff5f5; border-color: #ffc9c9; color: #a51111; }
.alert-warn { background: #fff9db; border-color: #ffe066; color: #7a5800; }
.alert-info { background: #e7f5ff; border-color: #a5d8ff; color: #0b4a7a; }

.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #e9edf2; color: #495057; vertical-align: middle; }
.tag-warn { background: #ffe3e3; color: #c92a2a; font-weight: bold; }
.tag-ok { background: #d3f9d8; color: #2b8a3e; }
.tag-imp { background: #fff0f6; color: #c2255c; font-weight: bold; }
.tag-ext { background: #f1f3f5; color: #868e96; }

/* list */
.list-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.list-head h2 { margin: 0; }
.searchbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar, .read-toolbar, .compose-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 8px 10px; }
.read-toolbar { border-radius: 8px; margin-bottom: 12px; }
.compose-actions { border-radius: 8px; margin-bottom: 12px; }
.toolbar .sep { flex: 1; }
.maillist { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-top: 0; table-layout: fixed; }
.maillist td { padding: 9px 8px; border-top: 1px solid #eef1f5; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.maillist tr { cursor: pointer; }
.maillist tr:hover { background: #f7f9fc; }
.maillist tr.unseen td { font-weight: bold; }
.maillist tr.unseen .c-subj a { color: var(--text); }
.maillist tr.seen .c-subj a { color: #4a5560; }
.maillist tr.warn { background: #fff8f8; }
.maillist .empty { text-align: center; color: var(--muted); padding: 50px; cursor: default; white-space: normal; }
.c-chk { width: 34px; } .c-star { width: 26px; } .c-from { width: 180px; } .c-date { width: 100px; color: var(--muted); font-size: 12px; text-align: right; } .c-size { width: 70px; color: var(--muted); font-size: 12px; text-align: right; }
.star { color: #c4cad3; } .star.on { color: #f59f00; }
.clip { margin-left: 4px; font-size: 12px; }
.pager { display: flex; gap: 4px; justify-content: center; margin: 16px 0; }
.pager a, .pager b { padding: 5px 10px; border-radius: 4px; border: 1px solid var(--line); background: #fff; }
.pager b { background: var(--primary); color: #fff; border-color: var(--primary); }
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: bold; }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* read */
.mail-view { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 20px 24px; }
.mail-subject { font-size: 20px; margin-bottom: 12px; word-break: break-word; }
.mail-meta { display: grid; grid-template-columns: 80px 1fr; gap: 4px 10px; margin: 0 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.mail-meta dt { color: var(--muted); }
.mail-meta dd { margin: 0; word-break: break-all; }
.attachments { background: #f8f9fb; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; margin-bottom: 12px; }
.attachments ul { list-style: none; margin: 4px 0 0; padding: 0; }
.attachments li { padding: 3px 0; }
.attachments li.danger a, .attachments li.danger span:first-child { color: var(--danger); }
.remote-images { background: #f8f9fb; padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; }
.mail-body { width: 100%; min-height: 300px; border: 0; display: block; }
.tracking, .comments, .share-info, .help-box, .danger-zone, .box { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px 18px; margin-top: 14px; }
.share-info { margin: 0 0 12px; }
.share-info .memo { background: #fff9db; padding: 8px 10px; border-radius: 6px; margin: 8px 0; }
.comment { border-bottom: 1px solid #eef1f5; padding: 8px 0; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }

/* compose */
.compose .row { display: flex; align-items: flex-start; gap: 8px; background: #fff; border: 1px solid var(--line); border-bottom: 0; padding: 8px 10px; }
.compose .row:first-of-type { border-radius: 8px 8px 0 0; }
.row-label { width: 70px; flex: 0 0 70px; padding-top: 7px; color: var(--muted); margin: 0; }
.grow { flex: 1; min-width: 0; }
.compose .row > input.grow { width: 100%; }
.rcpt { flex: 1; position: relative; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border: 1px solid #cfd6df; border-radius: 6px; padding: 3px 6px; min-height: 36px; background: #fff; cursor: text; }
.rcpt .chips { display: contents; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #e9edf2; border-radius: 14px; padding: 3px 4px 3px 10px; font-size: 13px; max-width: 100%; }
.chip.internal { background: #e8f0fe; color: #1859c4; }
.chip.invalid { background: #ffe3e3; color: #c92a2a; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; padding: 0 4px; }
.rcpt-input { flex: 1; min-width: 160px; border: 0 !important; outline: none !important; padding: 5px 2px !important; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 30; background: #fff; border: 1px solid #cfd6df; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.1); max-height: 280px; overflow-y: auto; }
.suggest div { padding: 7px 10px; cursor: pointer; }
.suggest div.on, .suggest div:hover { background: #e8f0fe; }
.filelist { list-style: none; padding: 0; margin: 6px 0 0; }
.filelist li { padding: 2px 0; }
.filelist li.bad { color: var(--danger); }
.editor-wrap { background: #fff; border: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.editor-toolbar button { border: 1px solid transparent; background: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; font: inherit; }
.editor-toolbar button:hover { background: #e9edf2; border-color: #d5dbe3; }
.editor-toolbar select { padding: 3px 6px; }
.editor-toolbar input[type=color] { width: 32px; height: 28px; padding: 0; border: 1px solid #d5dbe3; border-radius: 4px; }
.editor { min-height: 380px; padding: 14px 16px; outline: none; line-height: 1.6; overflow-wrap: anywhere; }
.editor img { max-width: 100%; }
.editor blockquote { margin: 8px 0 0 4px; padding-left: 10px; border-left: 2px solid #ccc; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 10px; width: 560px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; }
.modal-head, .modal-foot { padding: 12px 16px; display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.modal-foot { border-top: 1px solid var(--line); justify-content: flex-end; }
.modal .dir-filter { margin: 0 16px 8px; }
.dir-body { overflow-y: auto; padding: 0 16px 12px; flex: 1; }
.dept-group { margin-bottom: 10px; }
.dept-group legend { font-weight: bold; }
.person { display: block; margin: 0; padding: 4px 0; }
.share-users { max-height: 420px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.share-users .dir-filter { width: 100%; margin-bottom: 10px; }
.radio-row { display: flex; gap: 20px; margin-bottom: 10px; }
.radio-row label { display: inline-flex; gap: 6px; align-items: center; }
.share-form { max-width: 720px; }

/* grid tables */
.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); margin-bottom: 12px; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid #eef1f5; text-align: left; vertical-align: middle; }
.grid thead th { background: #f8f9fb; font-weight: bold; color: #495057; }
.grid tr.disabled td { color: var(--muted); background: #fafafa; }
.grid input[type=text] { padding: 5px 7px; }
.dept-card { margin-bottom: 18px; }
.dept-card h3 { display: flex; align-items: center; gap: 10px; }
.form-narrow { max-width: 560px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-suffix { display: flex; align-items: center; margin-top: 4px; }
.input-suffix input { flex: 1; border-radius: 6px 0 0 6px !important; min-width: 0; }
.input-suffix span { padding: 7px 10px; background: #f1f3f5; border: 1px solid #cfd6df; border-left: 0; border-radius: 0 6px 6px 0; color: var(--muted); white-space: nowrap; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.w-sm { width: 80px; } .w-md { width: 140px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.settings-form .setting { display: grid; grid-template-columns: 260px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.settings-form .setting label { margin: 0; padding-top: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat b { display: block; font-size: 26px; margin: 4px 0; }
.stat small { color: var(--muted); }
.stat.danger b { color: var(--danger); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* login / blank */
body.blank { background: linear-gradient(135deg, #e8f0fe, #f4f6f9); }
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 380px; max-width: 100%; background: #fff; padding: 32px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.login-box h1 { font-size: 22px; text-align: center; margin: 0 0 24px; }
.login-box .notice { background: #f8f9fb; border-radius: 6px; padding: 10px; font-size: 13px; margin-top: 12px; }
.center-box { max-width: 520px; margin: 80px auto; background: #fff; padding: 30px; border-radius: 12px; text-align: center; }

@media (max-width: 860px) {
  .menu-toggle { display: block; }
  .topsearch, .session-timer, .uname { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 25; }
  .sidebar.open { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .content { margin-left: 0; padding: 14px 12px 60px; }
  .c-size, .c-star { display: none; }
  .c-from { width: 110px; }
  .c-date { width: 70px; }
  .row2, .two-col, .settings-form .setting { grid-template-columns: 1fr; }
  .mail-view { padding: 14px; }
}
@media print {
  .topbar, .sidebar, .read-toolbar, .tracking { display: none; }
  .content { margin: 0; }
}
