:root {
  --bg: #0e1117;
  --surface: #151a23;
  --surface-2: #1b2230;
  --border: #28303f;
  --border-soft: #212836;
  --text: #e8ecf4;
  --muted: #8b96aa;
  --dim: #68738a;
  --accent: #5b8cff;
  --accent-2: #22c9a6;
  --danger: #ff6b6b;
  --warn: #f5b74a;
  --radius: 10px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input, textarea { font-family: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; background: #222b3a; padding: 1px 5px; border-radius: 4px; color: #b8c7e0; }
kbd { font: 11px ui-monospace, Consolas, monospace; background: #222b3a; border: 1px solid var(--border); border-bottom-width: 2px; padding: 1px 6px; border-radius: 4px; color: #c9d5e8; }

/* ---------- 通用控件 ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  transition: border-color .15s, background .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { border-color: #3c4961; background: #222b3b; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #6e9aff; border-color: #6e9aff; }
.btn.ghost { background: transparent; color: var(--muted); padding: 6px 10px; min-width: 32px; }
.btn.ghost:hover { color: var(--text); }
.btn.danger { background: transparent; border-color: #6a3038; color: #ff9a9a; }
.btn.danger:hover { background: #3a1e24; }
.btn.tiny { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; padding: 10px; margin-top: 14px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; padding: 0 4px; }
.icon-btn:hover { color: var(--text); }
.input {
  width: 100%;
  background: #101620;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 8px;
  outline: none;
  font-size: 13px;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,140,255,.13); }
.input::placeholder { color: #5d6779; }
textarea.input { resize: vertical; min-height: 72px; }
.form-error { color: #ff9a9a; font-size: 12px; min-height: 18px; margin-top: 8px; }

/* ---------- 登录 ---------- */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(900px 500px at 50% -10%, #1a2740 0%, var(--bg) 65%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.login-mark, .logo-badge { display: inline-flex; align-items: center; justify-content: center; font-weight: 800;
  letter-spacing: .5px; color: #fff; background: linear-gradient(135deg, #5b8cff, #2bb8a3); border-radius: 10px; }
.login-mark { width: 44px; height: 44px; font-size: 15px; margin-bottom: 18px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.login-hint { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-soft); font-size: 12px; color: var(--dim); line-height: 1.7; }

/* ---------- 顶栏 ---------- */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 62px; flex: 0 0 62px; display: flex; align-items: center; gap: 20px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.logo-badge { width: 28px; height: 28px; font-size: 10px; border-radius: 7px; }
.logo-text { font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.logo-tag { font-size: 10px; color: var(--accent-2); border: 1px solid #245c52; background: #16312d; padding: 1px 6px; border-radius: 4px; }
.search-box { position: relative; flex: 1 1 auto; max-width: 520px; display: flex; align-items: center; }
.search-icon { position: absolute; left: 12px; color: var(--dim); font-size: 18px; pointer-events: none; }
.search-box input { width: 100%; height: 36px; background: #101620; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 0 92px 0 34px; outline: none; font-size: 13px; }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,140,255,.12); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 66px; border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }
.result-count { position: absolute; right: 12px; color: var(--dim); font-size: 11px; pointer-events: none; }
.top-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

/* ---------- 提醒条 ---------- */
.alert-bar { display: flex; align-items: center; gap: 12px; padding: 9px 20px; font-size: 13px;
  background: #2a2114; border-bottom: 1px solid #50401f; color: #f5ce8b; }
.alert-bar .alert-link { background: transparent; border: 0; color: #ffd890; text-decoration: underline; font-size: 13px; padding: 0; }

/* ---------- 布局 ---------- */
.layout { flex: 1 1 auto; display: flex; min-height: 0; }
.sidebar { width: 196px; flex: 0 0 196px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px; overflow-y: auto; display: flex; flex-direction: column; }
.side-section { margin-bottom: 24px; }
.side-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); padding: 0 8px 8px; }
.side-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  border: 0; background: transparent; color: var(--muted); padding: 8px 10px; border-radius: 7px;
  font-size: 13px; text-align: left; margin-bottom: 2px; }
.side-item:hover { background: var(--surface-2); color: var(--text); }
.side-item.active { background: #1c2a48; color: #a9c2ff; font-weight: 600; }
.pill { font-size: 11px; background: #232c3b; color: var(--muted); border-radius: 10px; padding: 1px 7px; flex: 0 0 auto; }
.side-item.active .pill { background: #2b3d66; color: #c6d7ff; }
.cat-list { display: flex; flex-direction: column; gap: 2px; }
.cat-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  border: 0; background: transparent; color: var(--muted); padding: 6px 10px; border-radius: 7px;
  font-size: 12.5px; text-align: left; }
.cat-item:hover { background: var(--surface-2); color: var(--text); }
.cat-item.active { background: #16312d; color: #9ce8d3; font-weight: 600; }
.cat-item.active .pill { background: #22503f; color: #c8f5e5; }
.cat-item > span:first-child { display: flex; align-items: center; gap: 7px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-2); flex: 0 0 auto; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
.tag-chip { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  font-size: 12px; padding: 3px 9px; border-radius: 20px; }
.tag-chip:hover { border-color: var(--accent); color: var(--text); }
.tag-chip.active { background: #1c2a48; border-color: var(--accent); color: #bcd0ff; }
.tag-empty { color: var(--dim); font-size: 12px; padding: 2px 6px; }
.side-foot { margin-top: auto; font-size: 11px; color: var(--dim); line-height: 1.8; border-top: 1px solid var(--border-soft); padding: 12px 6px 2px; }

/* ---------- 表格 ---------- */
.main { flex: 1 1 auto; overflow: auto; min-width: 0; }
.table-wrap { min-width: 1240px; }
.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid th { position: sticky; top: 0; z-index: 2; background: #121822; color: var(--muted);
  font-size: 12px; font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; font-size: 13px; }
.grid tbody tr:hover { background: #171e2b; }
.grid tbody tr.row-overdue { box-shadow: inset 3px 0 0 var(--danger); }
.grid tbody tr.row-soon { box-shadow: inset 3px 0 0 var(--warn); }
.col-star { width: 38px; } .col-name { width: 14%; } .col-cat { width: 10%; } .col-url { width: 15%; }
.col-user { width: 14%; } .col-pass { width: 15%; } .col-tags { width: 11%; } .col-exp { width: 10%; }
.col-note { width: 11%; } .col-ops { width: 100px; }
.cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.strong { font-weight: 600; color: #f0f4fc; }
.star { border: 0; background: transparent; font-size: 17px; line-height: 1; padding: 2px; color: #4b5568; }
.star:hover { color: var(--warn); }
.star.on { color: var(--warn); }
.link-a { color: #8fb2ff; text-decoration: none; }
.link-a:hover { text-decoration: underline; }
.mini-btn { border: 0; background: transparent; color: #6f9bff; font-size: 12px; padding: 2px 5px; border-radius: 4px; }
.mini-btn:hover { background: #22304b; color: #b9d0ff; }
.mini-btn.del { color: #cf7c7c; }
.mini-btn.del:hover { background: #3a2229; color: #ffb3b3; }
.mask { color: var(--dim); letter-spacing: 2px; font-family: ui-monospace, Consolas, monospace; }
.mask.revealed { color: #d6e2f7; letter-spacing: 0; font-size: 12px; word-break: break-all; }
.cat-chip { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; color: #8fe0cd; background: #153029; border: 1px solid #245648;
  border-radius: 5px; padding: 1px 7px; vertical-align: middle; }
.cat-chip:hover { border-color: var(--accent-2); color: #c8fff0; }
.tag-mini { display: inline-block; font-size: 11px; color: #a7b8d4; background: #202a3a; border: 1px solid #2c384c;
  border-radius: 4px; padding: 1px 6px; margin: 1px 3px 1px 0; cursor: pointer; }
.tag-mini:hover { border-color: var(--accent); }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 5px; white-space: nowrap; }
.badge.muted { color: var(--dim); background: transparent; }
.badge.ok { color: #7f8ca3; background: #1c2431; }
.badge.warn { color: #ffd18a; background: #3a2c17; border: 1px solid #57411f; }
.badge.bad { color: #ffabab; background: #3a1f24; border: 1px solid #5d2b32; }
.empty { padding: 80px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 40px; color: #3a455a; margin-bottom: 12px; }
.empty-title { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--dim); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-mask { position: absolute; inset: 0; background: rgba(5,8,13,.72); backdrop-filter: blur(2px); }
.panel { position: relative; width: 100%; max-width: 700px; max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid #303a4d; border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.panel.narrow { max-width: 540px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-body { padding: 20px; }
.panel-foot { display: flex; align-items: center; gap: 8px; padding-top: 16px; margin-top: 6px; border-top: 1px solid var(--border-soft); }
.spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.wide { grid-column: 1 / -1; }
.form-row label { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-row label em { color: var(--danger); font-style: normal; }
.label-hint { font-weight: 400; color: var(--dim); font-size: 11px; }
.input-group { display: flex; gap: 6px; }
.input-group .input { flex: 1; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.tag-suggest button { font-size: 11px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); border-radius: 12px; padding: 1px 8px; }
.tag-suggest button:hover { border-color: var(--accent-2); color: var(--text); }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check-row input { accent-color: var(--accent); width: 15px; height: 15px; }
.notice { background: #16283a; border: 1px solid #274563; color: #b6d2ee; border-radius: 8px; padding: 11px 13px; font-size: 12.5px; line-height: 1.75; margin-bottom: 14px; }
.notice.warn { background: #2a2114; border-color: #57411f; color: #f3c98c; margin-top: 18px; }
.code-block { background: #0f141d; border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font: 12px/1.75 ui-monospace, SFMono-Regular, Consolas, monospace; color: #b9c8de; white-space: pre-wrap; word-break: break-all; }
.help-text { font-size: 12.5px; color: var(--muted); line-height: 1.8; margin: 10px 0 16px; }
.help-text strong { color: #ffcf99; }
.file-input { width: 100%; font-size: 12px; color: var(--muted); background: #101620; border: 1px dashed var(--border); padding: 12px; border-radius: 8px; }
.file-input::file-selector-button { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 6px; margin-right: 12px; cursor: pointer; }
.csv-preview { margin-top: 12px; background: #0f141d; border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font: 12px/1.7 ui-monospace, Consolas, monospace; color: #a9bcd6; white-space: pre-wrap; max-height: 180px; overflow: auto; }
.section-h { font-size: 13px; color: #c6d4ea; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft); }
.section-h:not(:first-child) { margin-top: 26px; }
.help-list { margin: 0 0 14px; padding-left: 20px; color: var(--muted); font-size: 12.5px; line-height: 1.9; }
.help-list li { margin-bottom: 4px; }
#passForm .form-row { margin-bottom: 12px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 100;
  background: #22304a; border: 1px solid #3a4d70; color: #eaf1ff; padding: 10px 20px; border-radius: 9px;
  font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.toast.bad { background: #3a2026; border-color: #6a3038; color: #ffc4c4; }

@media (max-width: 980px) {
  .sidebar { display: none; }
  .topbar { gap: 10px; padding: 0 12px; }
  .logo-text, .logo-tag { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}
