/* CyanCodex 本地管理端 - 液晶玻璃风格, 自动亮/暗/系统主题 */
:root {
  --bg: #f1f5f9; --card: #ffffff; --card-2: #f8fafc;
  --text: #0f172a; --muted: #64748b;
  --line: #e2e8f0; --primary: #0e7a3d; --primary-2: #16a34a;
  --danger: #dc2626; --warn: #d97706; --info: #2563eb;
  --shadow: 0 4px 20px rgba(15, 23, 42, .06);
  --radius: 14px;
}
[data-theme="dark"] {
  --bg: #0b1220; --card: #111a2c; --card-2: #0e1526;
  --text: #e2e8f0; --muted: #94a3b8;
  --line: #1e293b; --primary: #4ade80; --primary-2: #22c55e;
  --danger: #f87171; --warn: #fbbf24; --info: #60a5fa;
  --shadow: 0 4px 20px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(22, 163, 74, .10), transparent),
              radial-gradient(900px 500px at -10% 110%, rgba(37, 99, 235, .08), transparent),
              var(--bg);
  color: var(--text); min-height: 100vh; transition: background .4s, color .3s;
}
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }

/* ===== 登录 ===== */
#login-view { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
#login-view.hidden { display: none; }
.login-card {
  width: 400px; max-width: 94vw;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 34px 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  animation: rise .4s ease;
}
.login-logo { text-align: center; margin-bottom: 12px; }
.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-hint { color: var(--muted); font-size: 12px; margin-top: 16px; line-height: 1.7; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; font-size: 14px;
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; outline: none;
  transition: border .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
textarea { resize: vertical; line-height: 1.7; font-family: inherit; }
.err-text { color: var(--danger); font-size: 13px; margin: 8px 0; }

/* ===== 布局 ===== */
#app-view { display: flex; min-height: 100vh; }
#app-view.hidden { display: none; }
.sidebar {
  width: 226px; flex-shrink: 0;
  background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  backdrop-filter: blur(16px);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; font-weight: 700; font-size: 15px; }
.brand svg { flex-shrink: 0; }
#nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--muted); cursor: pointer; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--card-2); color: var(--text); }
.nav-item.active { background: rgba(22, 163, 74, .12); color: var(--primary); font-weight: 600; }
.nav-short {
  width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card-2); border: 1px solid var(--line);
  font-size: 12px; font-weight: 600;
}
.nav-item.active .nav-short { background: var(--primary); color: #fff; border-color: transparent; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 10.5px; border-radius: 20px; padding: 1px 7px; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sidebar-foot #whoami { margin-bottom: 8px; word-break: break-all; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px; background: color-mix(in srgb, var(--card) 70%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  position: sticky; top: 0; z-index: 30;
}
.topbar h2 { font-size: 17px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.conn-dot.ok { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.conn-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.2); }
.content { padding: 22px; max-width: 1280px; width: 100%; margin: 0 auto; animation: rise .3s ease; }

/* ===== 组件 ===== */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.btn {
  border: none; border-radius: 9px; padding: 9px 16px; font-size: 14px; cursor: pointer;
  background: var(--card-2); color: var(--text); transition: filter .15s, transform .05s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 12.5px; }
.btn.block { width: 100%; }
.icon-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.icon-btn:hover { color: var(--text); }

.grid { display: grid; gap: 14px; }
.grid.stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

.stat-card { text-align: left; }
.stat-card .num { font-size: 26px; font-weight: 700; margin: 4px 0; letter-spacing: .5px; }
.stat-card .lbl { color: var(--muted); font-size: 13px; }
.stat-card .num.green { color: var(--primary); }
.stat-card .num.red { color: var(--danger); }
.stat-card .num.blue { color: var(--info); }
.stat-card .num.amber { color: var(--warn); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: var(--card-2); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 13px; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; }
.tag.green { background: rgba(34,197,94,.14); color: var(--primary); }
.tag.red { background: rgba(239,68,68,.13); color: var(--danger); }
.tag.amber { background: rgba(217,119,6,.14); color: var(--warn); }
.tag.blue { background: rgba(37,99,235,.13); color: var(--info); }
.tag.gray { background: rgba(148,163,184,.15); color: var(--muted); }

.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--card-2); vertical-align: middle; }
.mini-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 6px; }
.thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.bold { font-weight: 600; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.click { cursor: pointer; }

/* 图表 */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap canvas { display: block; width: 100%; height: 260px; }
.chart-tip { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }

/* 空态 */
.empty { text-align: center; color: var(--muted); padding: 48px 0; font-size: 14px; }

/* 弹窗 */
#modal-mask {
  position: fixed; inset: 0; background: rgba(2, 6, 23, .55);
  backdrop-filter: blur(6px); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#modal-mask.hidden { display: none; }
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  width: 640px; max-width: 96vw; max-height: 90vh; overflow-y: auto;
  padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: rise .25s ease;
}
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }

/* toast */
#toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--primary);
  padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px;
  animation: slidein .3s ease; max-width: 360px;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

/* 邮箱主题选择等 */
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: none; background: none; padding: 7px 14px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--primary); color: #fff; }

/* 文本内容预览 */
.mail-preview-box {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #fff; color: #111; max-height: 420px; overflow-y: auto;
}
.mail-preview-box iframe { width: 100%; min-height: 380px; border: 0; }

/* 移动端 */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .content { padding: 14px; }
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ===== 聊天室实时消息 (气泡样式, 同聊天室观感) ===== */
.chat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chatwin {
  height: 470px; overflow-y: auto; padding: 14px 14px 18px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column;
}
.chatwin .chat-day { text-align: center; margin: 10px 0 2px; }
.chatwin .chat-day span {
  background: rgba(100,116,139,.16); color: var(--muted); font-size: 11.5px;
  padding: 2px 10px; border-radius: 20px;
}
.msg { display: flex; gap: 9px; margin-top: 12px; align-items: flex-start; animation: rise .18s ease; }
.msg.right { flex-direction: row-reverse; }
.msg .av {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  font-size: 13px; font-weight: 600; user-select: none;
}
.msg.official .av { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.msg .wrap { max-width: min(660px, 78%); }
.msg .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin: 0 4px 5px; }
.msg .meta b { color: var(--text); font-size: 12.5px; font-weight: 600; }
.msg.right .meta { justify-content: flex-end; }
.msg .bubble {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 12px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 2px rgba(15,23,42,.05); cursor: pointer;
}
.msg .bubble:hover { border-color: rgba(100,116,139,.55); }
.msg.right .bubble { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); }
.msg.deleted .bubble { background: rgba(100,116,139,.10); border-style: dashed; }
.msg.deleted .bubble .origin { text-decoration: line-through; color: var(--muted); }
.msg.flagged .bubble { border-color: rgba(220,38,38,.5); box-shadow: 0 0 0 3px rgba(220,38,38,.07); }
.msg .bubble .why { font-size: 11.5px; color: var(--danger); margin-top: 5px; }
/* 操作按钮平时隐藏(保持聊天室观感), 悬停或已撤回/判违规时显示; 点气泡可看详情 */
.msg .bubble .row-acts { display: none; gap: 6px; margin-top: 7px; padding-top: 6px; border-top: 1px dashed var(--line); }
.msg:hover .bubble .row-acts,
.msg.deleted .bubble .row-acts,
.msg.flagged .bubble .row-acts { display: flex; }
.msg .mini { font-size: 11.5px; padding: 2px 8px; }
.chatwin .empty { margin: auto; }
