:root {
  --navy: #16203a;
  --navy-2: #1f2c4d;
  --gold: #f6b932;
  --gold-soft: #fff4d6;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2533;
  --muted: #8a93a6;
  --line: #e8ecf3;
  --red: #e5534b;
  --green: #2faa6a;
  --blue: #3b82f6;
  --shadow: 0 6px 18px rgba(22, 32, 58, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ===== 登录态控制：未登录只显示登录界面，隐藏侧边栏与顶栏 ===== */
body:not(.authed) .sidebar, body:not(.authed) .topbar { display: none; }
body:not(.authed) .main { display: flex; align-items: center; justify-content: center; }
body:not(.authed) .view { overflow-y: auto; width: 100%; padding: 24px; }
body:not(.authed) .login-box { margin: 0 auto; }

/* ===== 移动端汉堡按钮 / 抽屉遮罩 ===== */
.menu-btn {
  display: none; border: none; background: transparent; color: var(--text);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; margin-right: 4px;
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(22, 32, 58, 0.45);
  z-index: 880;
}
body.nav-open .sidebar-backdrop { display: block; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 230px;
  flex: 0 0 230px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #cfd6e6;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--gold); display: grid; place-items: center; font-size: 22px;
  box-shadow: 0 4px 12px rgba(246, 185, 50, 0.4);
}
.brand-name { font-size: 16px; font-weight: 700; color: #fff; }
.brand-sub { font-size: 11px; letter-spacing: 2px; color: var(--gold); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 10px;
  color: #cfd6e6; text-decoration: none; font-size: 14.5px;
  cursor: pointer; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--gold); color: #16203a; font-weight: 700; }
.nav-ico { font-size: 17px; width: 20px; text-align: center; }
.nav-foot { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 12px; }

/* ===== 侧边栏自定义排序 ===== */
.nav-sort-btn {
  width: 100%; margin-bottom: 10px; padding: 8px 10px;
  background: rgba(255,255,255,0.06); color: #cfd6e6;
  border: 1px dashed rgba(255,255,255,0.22); border-radius: 9px;
  font-size: 13px; cursor: pointer; transition: background .15s, color .15s;
}
.nav-sort-btn:hover { background: rgba(255,255,255,0.13); color: #fff; }
.drag-handle { cursor: grab; color: rgba(255,255,255,0.32); font-size: 14px; user-select: none; padding-right: 2px; }
.sidebar.sorting .nav-item { background: rgba(246,185,50,0.10); border: 1px dashed rgba(246,185,50,0.40); }
.nav-item.dragging { opacity: .35; }
.nav-move { margin-left: auto; display: inline-flex; gap: 4px; }
.nav-mv {
  background: rgba(255,255,255,0.10); color: #cfd6e6; border: none;
  border-radius: 6px; width: 24px; height: 22px; font-size: 11px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-mv:disabled { opacity: .25; cursor: default; }
.nav-mv:hover:not(:disabled) { background: var(--gold); color: #16203a; }
.nav-hide { margin-left: 8px; font-size: 12px; color: rgba(255,255,255,0.62); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.nav-hide input { accent-color: var(--gold); cursor: pointer; }
.nav-hidden-item { opacity: .42; }
.nav-hidden-item .nav-label { text-decoration: line-through; }
.sidebar.sorting .nav-hidden-item { border-style: solid; border-color: rgba(255,255,255,0.18); }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== 设置页：侧边栏模块管理 ===== */
.mm-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.mm-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px;
}
.mm-row.mm-hidden { opacity: .5; }
.mm-row.dragging { opacity: .35; }
.mm-handle { cursor: grab; color: var(--muted); font-size: 17px; user-select: none; }
.mm-ico { font-size: 17px; width: 20px; text-align: center; }
.mm-name { flex: 1; font-size: 14px; color: var(--text); }
.mm-move { display: inline-flex; gap: 4px; }
.mm-toggle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; cursor: pointer; }

/* ===== 主区域 ===== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 20px; }
.page-sub { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.hq-badge {
  font-size: 12px; color: var(--navy); background: var(--gold-soft);
  padding: 6px 12px; border-radius: 20px; font-weight: 600;
}
.view { flex: 1; overflow-y: auto; padding: 26px; }

/* ===== 首页模块卡 ===== */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.module-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); cursor: pointer; border: 1px solid var(--line);
  transition: transform .12s, box-shadow .12s; position: relative;
}
.module-card:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(22,32,58,0.12); }
.module-card .mc-ico { font-size: 26px; }
.module-card .mc-title { font-weight: 700; margin-top: 10px; font-size: 16px; }
.module-card .mc-desc { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.module-card .mc-tag {
  position: absolute; top: 14px; right: 14px; font-size: 10.5px;
  background: #eef1f7; color: var(--muted); padding: 3px 8px; border-radius: 10px;
}
.module-card.ready .mc-tag { background: var(--gold-soft); color: #9a6b00; }

/* ===== 占位页 ===== */
.placeholder {
  background: var(--card); border-radius: var(--radius); padding: 40px;
  text-align: center; color: var(--muted); box-shadow: var(--shadow); border: 1px dashed var(--line);
}
.placeholder .ph-ico { font-size: 44px; }
.placeholder h2 { color: var(--text); margin: 14px 0 6px; }

/* ===== 清空大脑 ===== */
.brain-head { margin-bottom: 18px; }
.brain-title { font-size: 30px; font-weight: 800; letter-spacing: 1px; }
.brain-title .spark { color: var(--gold); }
.brain-desc { color: var(--muted); margin-top: 6px; font-size: 13.5px; }

.subtabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.subtab {
  padding: 9px 16px; border-radius: 20px; background: var(--card);
  border: 1px solid var(--line); cursor: pointer; font-size: 14px; font-weight: 600;
  color: var(--muted); display: flex; align-items: center; gap: 6px;
}
.subtab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.subtab .count {
  font-size: 11px; background: rgba(0,0,0,0.08); padding: 1px 7px; border-radius: 10px;
}
.subtab.active .count { background: rgba(255,255,255,0.22); }

/* 添加备忘录 */
.composer {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 18px; border: 1px solid var(--line);
}
.composer textarea {
  width: 100%; border: none; resize: vertical; min-height: 64px;
  font-size: 15px; font-family: inherit; outline: none; color: var(--text);
  background: var(--bg); border-radius: 10px; padding: 12px;
}
.composer .c-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }

/* 按钮 */
.btn {
  border: none; border-radius: 10px; padding: 9px 18px; font-size: 14px;
  font-weight: 600; cursor: pointer; font-family: inherit; transition: filter .12s;
}
.btn:hover { filter: brightness(0.96); }
.btn-primary { background: var(--gold); color: #16203a; }
.btn-ghost { background: #eef1f7; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: #e3e8f1; }
.btn-ghost:active { background: #d6dde8; }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn-ghost:disabled { background: #f1f3f8; color: var(--muted); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* 发送验证码「发送中」：明确的活动态（金色 + 旋转），避免灰色看不出在执行 */
.btn.is-sending {
  background: var(--gold) !important;
  color: #16203a !important;
  border-color: var(--gold) !important;
  cursor: wait !important;
  opacity: 1 !important;
}
.btn.is-sending::after {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 8px;
  border: 2px solid rgba(22,32,58,.35);
  border-top-color: #16203a;
  border-radius: 50%;
  vertical-align: -2px;
  animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* 发送验证码失败等原因提示：醒目红色 */
.login-hint.err { color: #e5484d; }

/* 备忘录卡片网格（一行四个） */
.memo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1100px){ .memo-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px){ .memo-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px){ .memo-grid { grid-template-columns: 1fr; } }

.memo-card {
  background: var(--card); border-radius: 12px; padding: 14px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; min-height: 110px;
  border-left: 4px solid var(--gold);
}
.memo-card .mc-content { font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; flex: 1; }
.memo-card .mc-time { font-size: 11.5px; color: var(--muted); }
.memo-card .mc-link {
  font-size: 12px; background: var(--gold-soft); color: #9a6b00;
  padding: 4px 9px; border-radius: 8px; align-self: flex-start; font-weight: 600;
}
.memo-card .mc-actions { display: flex; gap: 8px; }

/* 快速操作表格 */
.qa-table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.qa-table th, .qa-table td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line);
  font-size: 13.5px; vertical-align: middle;
}
.qa-table th { background: #fafbfe; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.qa-table tr:last-child td { border-bottom: none; }
.qa-table .qa-content { max-width: 280px; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.qa-table select, .qa-table input {
  font-family: inherit; font-size: 13.5px; padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--text); width: 100%;
}
.qa-table select { width: 120px; }
.qa-table input { width: 160px; }

/* 空状态 */
.empty {
  text-align: center; padding: 50px 20px; color: var(--muted);
  background: var(--card); border-radius: var(--radius); border: 1px dashed var(--line);
}
.empty .e-ico { font-size: 38px; }
.empty p { margin: 10px 0 0; }

/* 设置页 */
.settings-box { max-width: 560px; }
.set-card {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 16px;
}
.set-card h3 { margin: 0 0 6px; font-size: 16px; }
.set-card p { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.set-row { display: flex; gap: 10px; flex-wrap: wrap; }
.set-pagecfg { align-items: center; justify-content: space-between; }
.set-opt { display: flex; flex-direction: column; gap: 3px; }
.set-opt-label { font-size: 14px; font-weight: 600; color: var(--text); }
.set-opt-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
.about-card { margin-top: 8px; }
.about-ver { font-size: 14px; margin-bottom: 12px; }
.about-ver b { color: #4f7cff; }
.about-log { display: flex; flex-direction: column; gap: 14px; }
.log-item { border-left: 3px solid var(--line); padding-left: 12px; }
.log-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.log-v { font-weight: 700; font-size: 13px; color: var(--text); }
.log-date { font-size: 12px; color: var(--muted); }
.log-items { margin: 0; padding-left: 18px; }
.log-items li { font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ===== 设置页：折叠式卡片 ===== */
.set-card.collapsible { padding: 0; overflow: hidden; }
.set-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; cursor: pointer; user-select: none;
}
.set-card-title { font-size: 16px; font-weight: 700; color: var(--text); }
.set-caret { font-size: 13px; color: var(--muted); transition: transform .18s; }
.collapsible.collapsed .set-caret { transform: rotate(-90deg); }
.set-card-body { padding: 0 20px 20px; }
.collapsible.collapsed .set-card-body { display: none; }
.foot-card { padding: 16px 20px !important; }

/* 登录页：信任设备勾选 */
.trust-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 14px; cursor: pointer; }
.trust-row input { width: 16px; height: 16px; accent-color: var(--gold); }

/* ===== 账户管理 ===== */
.acct-section-title { font-size: 13.5px; font-weight: 700; color: var(--text); margin: 16px 0 10px; padding-left: 9px; border-left: 3px solid var(--gold); }
.acct-tip { font-size: 12px; color: var(--muted); margin: 8px 2px 0; line-height: 1.5; }
.acct-info { display: grid; grid-template-columns: 1fr; gap: 10px 18px; }
.acct-item { display: flex; flex-direction: column; gap: 2px; background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.acct-label { font-size: 12px; color: var(--muted); }
.acct-val { font-size: 14px; color: var(--text); font-weight: 600; word-break: break-all; }

/* 设备列表（信任设备 / 最近登录） */
.dev-list { display: flex; flex-direction: column; gap: 8px; }
.dev-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.dev-main { min-width: 0; }
.dev-model { font-size: 14px; font-weight: 600; color: var(--text); }
.dev-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dev-empty { font-size: 12.5px; color: var(--muted); padding: 8px 2px; }

/* 桌面端：账户信息两列 */
@media (min-width: 560px) {
  .acct-info { grid-template-columns: 1fr 1fr; }
}
.about-tip { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 12px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 999; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 登录 / 用户区 */
.login-box {
  max-width: 380px; margin: 8vh auto 0; background: var(--card);
  border-radius: var(--radius); padding: 32px 28px; box-shadow: var(--shadow);
  border: 1px solid var(--line); text-align: center;
}
.login-box h2 { margin: 10px 0 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; box-sizing: border-box; outline: none;
}
.login-input:focus { border-color: var(--gold); }
.login-hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; min-height: 16px; }
.auth-user { font-size: 13px; color: var(--text); margin-right: 8px; }
#auth-area { display: flex; align-items: center; }

/* 登录模式切换 */
.login-switch { display: flex; justify-content: center; gap: 14px; margin-top: 12px; font-size: 12.5px; }
.login-switch a { color: var(--blue); cursor: pointer; text-decoration: none; }
.login-switch a:hover { text-decoration: underline; }

/* 模态框（设置密码 / 安全验证） */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(22,32,58,.45);
  display: grid; place-items: center; z-index: 1000; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); padding: 26px 24px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; line-height: 1.6; }
.modal .login-input { margin-bottom: 4px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* 清空数据：强提醒内联输入框 */
.inline-input {
  display: inline-block; width: 96px; padding: 3px 8px; margin: 0 4px;
  border: 1px solid var(--red); border-radius: 8px; font-size: 13px;
  outline: none; box-sizing: border-box; vertical-align: baseline;
  background: var(--bg); color: var(--text);
}
.inline-input:focus { border-color: var(--gold); }
.clear-warn { color: #ff7a7a !important; font-size: 13.5px; line-height: 2.1; }

/* 用户管理表格标签 */
.tag-ok { color: var(--green); font-weight: 600; }
.tag-no { color: var(--muted); }

/* ============================================================
   响应式：移动端（≤820px）
   ============================================================ */
@media (max-width: 820px) {
  /* 侧边栏改为抽屉：默认隐藏，点汉堡滑出 */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 900;
    width: 80%; max-width: 300px; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: 0 0 40px rgba(0,0,0,.35);
    padding: 18px 14px;
  }
  body.nav-open .sidebar { transform: translateX(0); }

  /* 主区域占满全屏 */
  .main { width: 100%; }
  .topbar { padding: 12px 14px; }
  .topbar h1 { font-size: 17px; }
  .page-sub { font-size: 12px; }

  /* 显示汉堡按钮 */
  .menu-btn { display: inline-flex; align-items: center; }

  /* 内容区内边距收紧 */
  .view { padding: 16px; }

  /* 首页模块卡：两列网格，卡片更紧凑 */
  .module-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .module-card { padding: 14px; }
  .module-card .mc-ico { font-size: 22px; }
  .module-card .mc-title { font-size: 14.5px; }
  .module-card .mc-desc { font-size: 11.5px; }

  /* 通用卡片 / 设置卡片收窄 */
  .set-card { padding: 16px; }
  .composer, .placeholder, .brain-head { padding: 16px; }
  .subtabs { gap: 6px; }
  .subtab { padding: 8px 12px; font-size: 13px; }

  /* 登录框适配小屏 */
  .login-box { max-width: 100%; margin: 0 auto; padding: 26px 20px; }

  /* 模态框在手机上几乎占满，避免溢出 */
  .modal { max-width: 100%; width: 100%; padding: 22px 18px; }

  /* 安全验证/清空数据内联输入框在窄屏换行更友好 */
  .inline-input { width: 84px; font-size: 12.5px; }
  .clear-warn { line-height: 1.9; }
}

/* 超小屏（≤380px）进一步压缩 */
@media (max-width: 380px) {
  .module-grid { grid-template-columns: 1fr; }
  .login-box { padding: 22px 16px; }
}

