/* ===== 主题：浅色（默认）与深色，全部经 CSS 变量驱动；<html data-theme> 切换 ===== */
:root,
[data-theme='light'] {
  --bg: #f4f6f9; --panel: #ffffff; --panel2: #eef1f6; --border: #d8dee8;
  --text: #212733; --muted: #67707d; --accent: #2563eb; --green: #157347; --orange: #b45309; --red: #dc2626;
  --code-bg: #fdf3cd; --code-fg: #8a5a00;
  --badge-ok-bg: #dcf3e6; --badge-ok-fg: #157347;
  --badge-warn-bg: #fdeed2; --badge-warn-fg: #b45309;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
[data-theme='dark'] {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --border: #2a2f3a;
  --text: #d7dce4; --muted: #7d8590; --accent: #4f8cff; --green: #34c77b; --orange: #e8a33d; --red: #e5534b;
  --code-bg: #241f0e; --code-fg: #ffd666;
  --badge-ok-bg: #11301f; --badge-ok-fg: #34c77b;
  --badge-warn-bg: #33240f; --badge-warn-fg: #e8a33d;
  --shadow: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); font-size: 12px; min-height: 16px; }

/* 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 32px; width: 320px; text-align: center; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card input { width: 100%; padding: 9px 10px; margin: 14px 0 8px; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }
.login-card button { width: 100%; padding: 9px; background: var(--accent); color: #fff; border: 0; border-radius: 6px; cursor: pointer; }

/* 头部 */
header { display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.logo { font-weight: 600; font-size: 14px; }
.logo small { color: var(--muted); font-weight: 400; margin-left: 4px; }
nav { display: flex; gap: 4px; flex: 1; }
nav a { color: var(--muted); text-decoration: none; padding: 5px 12px; border-radius: 6px; }
nav a.active { color: var(--text); background: var(--panel2); }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-right a { color: var(--muted); text-decoration: none; font-size: 12px; }
.dot { color: var(--muted); }
.dot.ok { color: var(--green); } .dot.bad { color: var(--red); }

main { padding: 16px 18px; max-width: 1280px; }

/* 工具条 & 表格 */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
input, select, button { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; font-size: 12.5px; }
input:focus, select:focus { outline: 1px solid var(--accent); }
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button:disabled { opacity: .5; cursor: default; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--panel2); }
td.wrap { white-space: normal; word-break: break-all; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel2); }
tbody tr:last-child td { border-bottom: 0; }

.code-chip { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--code-bg); color: var(--code-fg); padding: 2px 8px; border-radius: 4px; font-size: 13px; letter-spacing: 1px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; }
.b-inbox { background: var(--badge-ok-bg); color: var(--badge-ok-fg); }
.b-quarantine { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.b-ok { color: var(--green); } .b-warn { color: var(--orange); } .b-muted { color: var(--muted); }
.alias-chip { color: var(--accent); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* 统计块 */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.tile .v { font-size: 20px; font-weight: 600; margin-top: 2px; }
.tile .v.green { color: var(--green); } .tile .v.orange { color: var(--orange); } .tile .v.red { color: var(--red); }

/* 抽屉详情 */
#drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; display: flex; justify-content: flex-end; }
#drawer { width: min(720px, 92vw); height: 100vh; background: var(--panel); border-left: 1px solid var(--border); padding: 18px; overflow-y: auto; }
#drawer h3 { margin: 0 0 8px; word-break: break-all; }
#drawer .kv { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; margin: 10px 0; font-size: 12.5px; }
#drawer .kv .k { color: var(--muted); }
#drawer pre { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; white-space: pre-wrap; word-break: break-all; font-size: 12px; max-height: 340px; overflow-y: auto; }
#drawer iframe { width: 100%; height: 420px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
#drawer .drawer-actions { display: flex; gap: 8px; margin: 10px 0; }

/* 表单区 */
.form-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.section { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; }
.section h4 { margin: 0 0 10px; font-size: 13px; }
.token-show { font-family: ui-monospace, Menlo, monospace; background: var(--code-bg); color: var(--code-fg); padding: 6px 10px; border-radius: 6px; word-break: break-all; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px 14px; z-index: 20; font-size: 12.5px; max-width: 420px; }

/* 免登录快速取码 */
body.public-mode nav a:not([data-tab="getcode"]) { display: none; }
.gc-code-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 18px; text-align: center; }
.code-big { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 40px; letter-spacing: 8px; color: var(--code-fg); background: var(--code-bg); border-radius: 8px; padding: 14px 10px; margin-bottom: 10px; user-select: all; }

/* 用户端（公网同事邮箱） */
.ulink { color: var(--accent); font-size: 12.5px; text-decoration: none; }
.ulink:hover { text-decoration: underline; }
.banner { border-left: 3px solid var(--accent); }
.banner h4 { margin: 0 0 8px; }
.banner p { margin: 6px 0; }
#user-app header { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
#user-app header .logo { font-weight: 600; font-size: 14px; }
#user-app main { padding: 16px 18px; max-width: 1080px; margin: 0 auto; }
#user-app .header-right a { color: var(--muted); text-decoration: none; font-size: 12px; margin-left: 12px; }
