:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ee;
  --dim: #9aa1b1;
  --accent: #7c5cff;
  --ok: #34a853;
  --warn: #f9ab00;
  --bad: #e5484d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
code {
  background: var(--panel-2); padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 20px 0 6px; color: var(--dim); }

/* --- 输入控件 --- */
input, select, textarea, button {
  font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { width: 100%; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
button { cursor: pointer; }
button:hover { background: #262b36; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
button.danger:hover { background: rgba(229,72,77,.12); }
label { display: block; font-size: 12px; color: var(--dim); }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: 4px; color: var(--text); }
label.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
label.chk input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 14px 0; padding: 10px 12px; }
legend { font-size: 12px; color: var(--dim); padding: 0 4px; }

/* --- 登录 / 初始化 --- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate .card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 24px;
}
.gate .card input { width: 100%; margin-bottom: 10px; }
.gate .card button { width: 100%; }
.hint { color: var(--dim); font-size: 12px; margin: 8px 0 12px; }
.warn { color: var(--warn); font-size: 12px; margin: 8px 0 12px; }
.err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }
.ok { color: var(--ok); font-size: 13px; margin-top: 6px; }

/* --- 顶栏 --- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; color: var(--dim); font-size: 12px; }
.stats b { color: var(--text); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.toolbar #q { min-width: 200px; flex: 1 1 200px; }
.count { color: var(--dim); font-size: 12px; margin-left: auto; }

/* --- 账号列表 --- */
.list { padding: 12px 16px 60px; display: grid; gap: 10px; }
.empty { padding: 40px; text-align: center; color: var(--dim); }
.acct {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
}
.acct.dead { opacity: .55; }
.acct.dead .email { text-decoration: line-through; }
.acct-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.email {
  font-weight: 600; font-family: ui-monospace, Menlo, monospace; font-size: 14px;
  word-break: break-all;
}
.badge {
  font-size: 11px; padding: 2px 7px; border-radius: 20px;
  border: 1px solid var(--line); color: var(--dim); white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: rgba(52,167,83,.5); }
.badge.dead { color: var(--bad); border-color: rgba(229,72,77,.5); }
.badge.suspect { color: var(--warn); border-color: rgba(249,171,0,.5); }
.badge.label { color: var(--dim); }
.acct-actions { margin-left: auto; display: flex; gap: 6px; }
.acct-actions button { padding: 5px 9px; font-size: 12px; }

/* 凭据行 */
.creds { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.field { display: flex; align-items: center; gap: 6px; font-size: 13px; min-width: 0; }
.field .k { color: var(--dim); font-size: 12px; white-space: nowrap; }
.field .v {
  font-family: ui-monospace, Menlo, monospace; word-break: break-all;
  background: var(--panel-2); padding: 2px 6px; border-radius: 5px;
}
.field .v.masked { letter-spacing: 2px; color: var(--dim); }
.mini { padding: 3px 7px !important; font-size: 11px !important; }

/* 2FA */
.totp { display: flex; align-items: center; gap: 8px; }
.code {
  font-family: ui-monospace, Menlo, monospace; font-size: 20px; font-weight: 700;
  letter-spacing: 3px; color: var(--accent); cursor: pointer; user-select: all;
}
.code.expiring { color: var(--warn); }
.ring { width: 22px; height: 22px; flex: 0 0 22px; }
.ring circle { fill: none; stroke-width: 3; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--accent); transition: stroke-dashoffset .95s linear; }
.ring.expiring .fg { stroke: var(--warn); }

/* 服务勾选 */
.svc-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 12px; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--line); background: transparent; color: var(--dim);
  user-select: none;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on { color: #fff; font-weight: 600; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .9; }
.svc-checks { display: flex; gap: 8px; flex-wrap: wrap; }
.svc-checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.svc-checks input { width: auto; margin: 0; }

/* --- 弹窗 --- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: grid; place-items: center; padding: 16px; z-index: 50; overflow: auto;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
}
.modal-card.wide { max-width: 760px; }
.modal-card label { margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filebtn {
  display: inline-block; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 14px; color: var(--text);
}
.filebtn input { display: none; }
#form-password input { width: 100%; margin-bottom: 8px; }

/* 服务管理列表 */
.svc-list { display: grid; gap: 6px; margin: 10px 0; }
.svc-item { display: flex; align-items: center; gap: 8px; }
.svc-item input[type=text] { flex: 1; }
.svc-item input[type=color] { width: 42px; padding: 2px; }
.svc-item .used { color: var(--dim); font-size: 12px; white-space: nowrap; }
.svc-add { display: flex; gap: 8px; margin-top: 10px; }
.svc-add input[type=text] { flex: 1; }
.svc-add input[type=color] { width: 46px; padding: 2px; }

/* 导入预览 */
.imp-opts { display: grid; gap: 10px; margin: 12px 0; }
.imp-result { margin-top: 12px; font-size: 13px; }
.imp-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.imp-table th, .imp-table td {
  border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left;
  font-family: ui-monospace, Menlo, monospace; word-break: break-all;
}
.imp-table th { color: var(--dim); font-family: inherit; }
.imp-table tr.bad td { color: var(--warn); }

/* 2FA 取码窗口 */
.decode-out {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 12px 0;
}
.decode-code { display: flex; align-items: center; gap: 10px; }
.decode-code .code { font-size: 32px; letter-spacing: 5px; }
.decode-code .ring { width: 28px; height: 28px; flex: 0 0 28px; }
#d-meta { margin: 8px 0 0; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 20px; z-index: 100; font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .topbar-actions { width: 100%; margin-left: 0; }
  .topbar-actions button { flex: 1 1 auto; }
  .count { margin-left: 0; }
}
