/* WeiSAT 项目维护系统 —— 配色与版面沿用信箱助理（WeiSAT MailBox）/ WeiSAT Desk */
:root {
  --bg: #F6F8FC;
  --panel: #EEF2F8;
  --card: #FFFFFF;
  --text: #1F1F1F;
  --muted: #5E5E5E;
  --hint: #80868B;
  --line: #E1E3E1;
  --accent: #0B57D0;
  --accent-soft: #D3E3FD;
  --hover: #E9EEF6;
  --field: #F0F4F9;
  --red: #B3261E;   --red-bg: #FCE8E6;
  --yellow: #8D5D00; --yellow-bg: #FEF7E0;
  --green: #137333; --green-bg: #E6F4EA;
  --purple: #7B1FA2; --purple-bg: #F3E8FD;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.6 "Microsoft JhengHei UI", "Microsoft YaHei UI", "PingFang TC", "PingFang SC", "Noto Sans CJK TC", "Segoe UI", sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.ic { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* 顶栏 */
.top { display: flex; align-items: center; gap: 10px; padding: 12px 16px 10px; padding-top: max(12px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 16px; }
.brand b { font-weight: 600; }
.brand-zh { color: var(--muted); }
.dots { display: inline-grid; grid-template-columns: 8px 8px; gap: 2px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; }
.dots.big { grid-template-columns: 14px 14px; gap: 4px; }
.dots.big i { width: 14px; height: 14px; }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icbtn {
  border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none;
}
.icbtn:hover { background: var(--hover); color: var(--accent); }

/* 三栏 */
.cols { flex: 1; min-height: 0; display: grid; grid-template-columns: 240px 360px minmax(0, 1fr); gap: 12px; padding: 0 16px 16px; }
.card { background: var(--card); border-radius: 16px; min-height: 0; overflow: auto; }
.left { background: var(--panel); border-radius: 24px; padding: 14px 10px; overflow: auto; }
.nav-item {
  width: 100%; border: 0; background: transparent; display: flex; align-items: center; gap: 12px;
  padding: 0 14px; height: 40px; border-radius: 20px; text-align: left;
}
.nav-item:hover { background: var(--hover); }
.nav-item.sel { background: var(--accent-soft); color: #041E49; font-weight: 600; }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-new { width: 100%; border: 0; background: #C2E7FF; color: #001D35; height: 52px; border-radius: 16px; display: flex; align-items: center;
  gap: 12px; padding: 0 18px; font-weight: 600; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(60,64,67,.15); }
.nav-new:hover { box-shadow: 0 1px 3px rgba(60,64,67,.3); }
.nav-new.alt { background: #fff; color: var(--accent); height: 40px; box-shadow: none; border: 1px solid var(--line); }
.badge { min-width: 22px; height: 20px; border-radius: 10px; padding: 0 6px; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-weight: 600; }
.badge.red { background: var(--red); }
.badge.soft { background: #DDE3EA; color: #444746; }
.section { color: var(--muted); font-size: 12px; padding: 16px 14px 6px; }

.mid-head, .right-head { padding: 16px 18px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.mid-head h2, .right-head h2 { margin: 0; font-size: 16px; }
.mid-head p, .right-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.hrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hrow h2 { flex: 1; min-width: 0; }
.row-item { padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row-item:hover { background: var(--hover); }
.row-item.sel { background: var(--accent-soft); }
.row-item .t { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-item .m { margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.tag { border-radius: 10px; padding: 0 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.red { background: var(--red-bg); color: var(--red); }
.tag.yellow { background: var(--yellow-bg); color: var(--yellow); }
.tag.green { background: var(--green-bg); color: var(--green); }
.tag.blue { background: var(--accent-soft); color: var(--accent); }
.tag.purple { background: var(--purple-bg); color: var(--purple); }
.tag.grey { background: #EEF0F2; color: #444746; font-weight: 500; }

.empty { padding: 48px 28px; text-align: center; color: var(--muted); }
.empty .big { font-size: 40px; color: #C4C7C5; line-height: 1; margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 15px; }
.empty p { margin: 0 auto; max-width: 360px; font-size: 13px; }
.body { padding: 16px 18px; }
.btn { border: 1px solid #C4C7C5; background: #fff; border-radius: 18px; height: 34px; padding: 0 16px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0842A0; }
.btn.wide { width: 100%; height: 42px; }
.btn:disabled { opacity: .5; cursor: default; }
.mini { border: 0; background: var(--hover); color: var(--accent); border-radius: 12px; height: 26px; padding: 0 10px; font-size: 12px; white-space: nowrap; }
.mini:hover { background: var(--accent-soft); }
.mini.primary { background: var(--accent); color: #fff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* 对话 */
.thread-wrap { display: flex; flex-direction: column; height: 100%; }
.thread { flex: 1; overflow: auto; padding: 12px 18px 6px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; display: flex; flex-direction: column; }
.msg .who { font-size: 11px; color: var(--hint); margin: 0 6px 2px; }
.msg .b { padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; user-select: text; }
.msg.us { align-self: flex-start; }
.msg.us .b { background: var(--panel); border-top-left-radius: 4px; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.me .b { background: var(--accent); color: #fff; border-top-right-radius: 4px; }
.msg.colleague .b { background: #E8F0E8; border-top-left-radius: 4px; }
.msg.admin .b { background: #E6F4EA; border-top-left-radius: 4px; }
.msg.internal { align-self: center; max-width: 92%; }
.msg.internal .b { background: var(--yellow-bg); color: var(--yellow); border-radius: 10px; font-size: 13px; }
.msg.system .b { background: #F1F3F4; }
.msg .time { font-size: 11px; color: var(--hint); margin: 2px 6px 0; }
.qs { margin-top: 6px; display: flex; flex-direction: column; gap: 8px; }
.qcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.qcard .q { font-weight: 600; }
.qcard .why { color: var(--muted); font-size: 12px; }
.qcard .opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.opt { border: 1px solid #C4C7C5; background: #fff; border-radius: 8px; padding: 3px 10px; font-size: 13px; }
.opt:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.confirm { margin: 6px 18px 0; border: 2px solid var(--accent-soft); background: #F5F9FF; border-radius: 14px; padding: 12px 14px; }
.confirm .t { font-weight: 600; margin-bottom: 4px; }
.confirm pre { white-space: pre-wrap; margin: 0; font: inherit; font-size: 13px; user-select: text; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px 14px; border-top: 1px solid var(--line);
  padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.composer textarea { flex: 1; min-height: 40px; height: 40px; overflow-y: hidden; max-height: 160px; resize: none; background: var(--field); border: 1px solid #C4C7C5;
  border-radius: 20px; padding: 8px 14px; outline: 0; line-height: 1.5; }
.composer textarea:focus { background: #fff; border-color: var(--accent); }
.composer .opts-inline { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sendbtn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.sendbtn:disabled { background: #C4C7C5; }

/* 后台 */
.kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 4px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; user-select: text; }
h3.sec { font-size: 13px; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.alertbox { border-radius: 12px; padding: 10px 12px; margin: 0 0 8px; font-size: 13px; }
.alertbox .t { font-weight: 600; }
.alertbox pre { white-space: pre-wrap; margin: 4px 0 0; font: inherit; user-select: text; }
.alertbox.red { background: var(--red-bg); color: var(--red); }
.alertbox.yellow { background: var(--yellow-bg); color: var(--yellow); }
.alertbox.blue { background: var(--accent-soft); color: #041E49; }
.alertbox.quiet { background: #F1F3F4; color: var(--muted); }
.alertbox .btn, .alertbox .mini { color: var(--text); }
.note { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: 12px; }
.note .m { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.note .reason { margin-top: 4px; color: var(--text); }
.doc { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: 13px; }
.doc .what { flex: 1; min-width: 0; font-weight: 600; }
.doc select { font-size: 12px; border: 1px solid #C4C7C5; border-radius: 6px; padding: 2px 4px; background: #fff; }
form.edit { padding: 16px 18px; }
form.edit label { display: block; margin-bottom: 10px; }
form.edit label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
form.edit input, form.edit select, form.edit textarea {
  width: 100%; border: 1px solid #C4C7C5; border-radius: 8px; padding: 7px 10px; background: #fff; outline: 0; font-size: 13px;
}
form.edit input[type=checkbox] { width: auto; }
form.edit .chk { display: flex; align-items: center; gap: 8px; }
form.edit input:focus, form.edit select:focus, form.edit textarea:focus { border-color: var(--accent); }
form.edit .err { color: var(--red); font-size: 12px; min-height: 18px; margin: 0; }
.secret { background: var(--yellow-bg); color: var(--yellow); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 0 18px 12px; user-select: text; }
.secret code { font: 600 16px/1.4 Consolas, monospace; color: var(--text); }

/* 登入 */
.overlay { position: fixed; inset: 0; background: rgba(246, 248, 252, .97); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.pair { width: 400px; max-width: 100%; padding: 30px 32px; text-align: center; box-shadow: 0 2px 12px rgba(60, 64, 67, .15); overflow: visible; }
.pair h1 { font-size: 19px; margin: 16px 0 6px; }
.pair p { margin: 0 0 14px; font-size: 13px; }
.pair input { width: 100%; height: 42px; border: 1px solid #C4C7C5; border-radius: 21px; padding: 0 16px; outline: 0; margin-bottom: 10px; background: #fff; }
.pair input:focus { border-color: var(--accent); }
.err { color: var(--red); min-height: 20px; margin: 8px 0 0 !important; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #303030; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.2); z-index: 30; max-width: calc(100% - 32px); }

/* 手机：一次只显示一栏（列表 → 内容），左栏变成上方横向的选单 */
@media (max-width: 800px) {
  .top { padding: 8px 12px; }
  .who { display: none; }
  .cols { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 8px; padding: 0 0 0; }
  .left { border-radius: 0; padding: 6px 10px; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; white-space: nowrap; background: transparent; }
  .left .section { display: none; }
  .nav-item, .nav-new, .nav-new.alt { width: auto; height: 34px; border-radius: 17px; padding: 0 12px; margin: 0; flex: none; box-shadow: none; }
  .nav-item .label { overflow: visible; }
  .card { border-radius: 16px 16px 0 0; }
  body.detail .left, body.detail .mid { display: none; }
  body:not(.detail) .right { display: none; }
  body.detail .cols { grid-template-rows: minmax(0, 1fr); }
  .msg { max-width: 90%; }
}
