/* ============ Vault · 设计系统 ============ */
:root {
  --c-blue: #3b82f6;
  --c-cyan: #06b6d4;
  --c-violet: #8b5cf6;
  --c-amber: #f59e0b;
  --c-pink: #ec4899;
  --c-green: #10b981;
  --c-indigo: #6366f1;
  --c-red: #ef4444;
  --c-gray: #64748b;

  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #0b0e14;
  --bg-elev: #11151d;
  --bg-card: #151a23;
  --bg-hover: #1b2130;
  --bg-input: #0e131b;
  --line: #222a38;
  --line-soft: #1a212d;
  --fg: #e6ebf4;
  --fg-dim: #8b96a8;
  --fg-faint: #5a6478;
  --accent: #4f8ef7;
  --accent-fg: #fff;
  --accent-soft: rgba(79, 142, 247, .13);
  --shadow: 0 10px 34px rgba(0, 0, 0, .5);
  --glow: radial-gradient(900px 420px at 12% -8%, rgba(79,142,247,.16), transparent 65%),
          radial-gradient(700px 380px at 92% 8%, rgba(139,92,246,.12), transparent 60%);
}

html[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f0f3f9;
  --bg-input: #f7f9fc;
  --line: #e2e8f2;
  --line-soft: #edf1f7;
  --fg: #16202f;
  --fg-dim: #5d6b80;
  --fg-faint: #97a3b6;
  --accent: #2563eb;
  --accent-fg: #fff;
  --accent-soft: rgba(37, 99, 235, .09);
  --shadow: 0 8px 26px rgba(22, 32, 47, .09);
  --glow: radial-gradient(900px 420px at 12% -8%, rgba(37,99,235,.08), transparent 65%),
          radial-gradient(700px 380px at 92% 8%, rgba(139,92,246,.07), transparent 60%);
}

* { box-sizing: border-box; }

/* hidden 属性必须始终生效：自定义的 display 规则会覆盖它 */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 99px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-faint); background-clip: padding-box; }

/* ============ 通用 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--fg);
  font-weight: 500; font-size: 13.5px;
  transition: all .18s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--fg-faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-fg);
  box-shadow: 0 2px 12px rgba(79, 142, 247, .28);
}
.btn.primary:hover { filter: brightness(1.09); box-shadow: 0 4px 18px rgba(79, 142, 247, .36); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.danger { color: var(--c-red); border-color: rgba(239, 68, 68, .35); }
.btn.danger:hover { background: rgba(239, 68, 68, .1); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--fg-dim);
  transition: all .16s var(--ease);
  flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
.icon-btn svg { width: 17px; height: 17px; }

.link-btn {
  background: none; border: none; padding: 6px 0;
  color: var(--accent); font-size: 13px;
  text-align: left; text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }

.field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
.field > span {
  font-size: 12.5px; font-weight: 500; color: var(--fg-dim);
  display: flex; align-items: center; gap: 6px;
}
.field > span em {
  font-style: normal; font-weight: 400;
  color: var(--fg-faint); font-size: 11.5px;
}
.field > span em b { color: var(--c-amber); font-weight: 600; }

.field input, .field textarea, .select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-size: 13.5px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
  outline: none;
}
.field input:focus, .field textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 62px; line-height: 1.6; }
.select { appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b96a8' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 13px;
}
.field-row { display: flex; gap: 12px; align-items: flex-end; }
.field-row > * { flex: 1; }
.field.inline { margin-bottom: 0; }

.check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--fg-dim); cursor: pointer;
  margin-bottom: 14px; user-select: none;
}
.check input {
  appearance: none; width: 17px; height: 17px; flex: none;
  border: 1.5px solid var(--line); border-radius: 5px;
  background: var(--bg-input); cursor: pointer;
  transition: all .16s var(--ease); position: relative;
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after {
  content: ''; position: absolute; left: 5px; top: 1.5px;
  width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px;
  color: var(--fg-faint); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .06em;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line-soft);
}

.msg { font-size: 12.5px; margin: 8px 0 0; min-height: 0; color: var(--fg-dim); }
.msg.err { color: var(--c-red); }
.msg.ok { color: var(--c-green); }

.tiny { font-size: 11.5px; }
.dim { color: var(--fg-dim); }
.danger { color: var(--c-red); }
.grow { flex: 1; }

kbd {
  display: inline-block; padding: 1px 5px;
  font-family: var(--mono); font-size: 10.5px;
  background: var(--bg-hover); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 4px;
  color: var(--fg-dim);
}

/* ============ 闸门页 ============ */
.gate {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.gate-bg {
  position: fixed; inset: 0; z-index: -1;
  background: var(--glow), var(--bg);
}
.gate-card {
  width: 100%; max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 28px 26px;
  box-shadow: var(--shadow);
  animation: rise .5s var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.brand { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.brand-mark {
  width: 44px; height: 44px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--accent), var(--c-violet));
  color: #fff;
  box-shadow: 0 6px 20px rgba(79, 142, 247, .34);
}
.brand-mark svg { width: 23px; height: 23px; }
.brand-mark.sm { width: 32px; height: 32px; border-radius: 10px; box-shadow: none; }
.brand-mark.sm svg { width: 17px; height: 17px; }
.brand h1 {
  margin: 0; font-size: 21px; font-weight: 650;
  letter-spacing: -.015em;
}
.brand-sub {
  margin: 1px 0 0; font-size: 11.5px;
  color: var(--fg-faint); letter-spacing: .02em;
}

.gate-form h2 {
  margin: 0 0 6px; font-size: 15.5px; font-weight: 600;
}
.hint-text {
  margin: 0 0 18px; font-size: 12.5px;
  color: var(--fg-dim); line-height: 1.65;
}
.hint-text strong { color: var(--fg); font-weight: 600; }

.warn-box {
  margin: 4px 0 16px;
  padding: 10px 12px;
  background: rgba(245, 158, 11, .09);
  border: 1px solid rgba(245, 158, 11, .26);
  border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.65;
  color: #e8b06a;
}
html[data-theme="light"] .warn-box { color: #92620b; }
.warn-box b { font-weight: 650; }

.hint-line {
  margin: -4px 0 14px; padding: 8px 11px;
  background: var(--bg-hover); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--fg-dim);
  border-left: 2px solid var(--accent);
}

.gate-foot {
  margin: 20px 0 0; font-size: 11px;
  color: var(--fg-faint); letter-spacing: .03em;
}

/* 密码强度条 */
.strength {
  display: flex; align-items: center; gap: 4px;
  margin-top: 7px; height: 14px;
}
.strength i {
  flex: 1; height: 3px; border-radius: 99px;
  background: var(--line); transition: background .25s var(--ease);
}
.strength[data-score="1"] i:nth-child(-n+1) { background: var(--c-red); }
.strength[data-score="2"] i:nth-child(-n+2) { background: var(--c-amber); }
.strength[data-score="3"] i:nth-child(-n+3) { background: var(--c-cyan); }
.strength[data-score="4"] i { background: var(--c-green); }
.strength span {
  font-size: 11px; color: var(--fg-faint);
  min-width: 30px; text-align: right;
}

/* ============ 主布局 ============ */
.app {
  display: grid;
  grid-template-columns: 258px 1fr;
  height: 100vh; height: 100dvh;
}

/* ---- 侧栏 ---- */
.sidebar {
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  min-height: 0;
}
.side-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px 14px;
}
.side-brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.side-brand strong { font-size: 15px; font-weight: 650; display: block; line-height: 1.2; }
.side-brand small {
  font-size: 11px; color: var(--fg-faint);
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.side-search {
  position: relative;
  margin: 0 12px 12px;
  display: flex; align-items: center;
}
.side-search svg {
  position: absolute; left: 10px;
  width: 15px; height: 15px; color: var(--fg-faint);
  pointer-events: none;
}
.side-search input {
  width: 100%; height: 34px;
  padding: 0 32px 0 32px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px; outline: none;
  transition: all .16s var(--ease);
}
.side-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.side-search input::-webkit-search-cancel-button { display: none; }
.side-search kbd {
  position: absolute; right: 8px;
  pointer-events: none; opacity: .6;
}

.side-nav {
  display: flex; flex-direction: column; gap: 1px;
  padding: 0 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--fg-dim);
  font-size: 13.5px; font-weight: 500;
  text-align: left; width: 100%;
  transition: all .15s var(--ease);
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav-item span { flex: 1; }
.nav-item em {
  font-style: normal; font-size: 11px;
  padding: 1px 6px; border-radius: 99px;
  background: var(--bg-hover); color: var(--fg-faint);
}
.nav-item:hover { background: var(--bg-hover); color: var(--fg); }
.nav-item.active {
  background: var(--accent-soft); color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-item.active em { background: rgba(79,142,247,.18); color: var(--accent); }

.side-filters {
  flex: 1; overflow-y: auto;
  padding: 16px 8px 8px; min-height: 0;
}
.side-label {
  margin: 0 0 7px; padding: 0 10px;
  font-size: 10.5px; font-weight: 600;
  color: var(--fg-faint);
  text-transform: uppercase; letter-spacing: .07em;
}
.cat-list { display: flex; flex-direction: column; gap: 1px; }
.cat-item {
  display: flex; align-items: center; gap: 9px;
  height: 31px; padding: 0 10px;
  border: none; border-radius: 7px;
  background: transparent; color: var(--fg-dim);
  font-size: 13px; text-align: left; width: 100%;
  transition: all .14s var(--ease);
}
.cat-item em {
  margin-left: auto; font-style: normal;
  font-size: 11px; color: var(--fg-faint);
}
.cat-item:hover { background: var(--bg-hover); color: var(--fg); }
.cat-item.active { background: var(--bg-hover); color: var(--fg); font-weight: 550; }
.dot {
  width: 7px; height: 7px; border-radius: 99px;
  flex: none; opacity: .85;
}
.dot.warn { background: var(--c-amber); }
.dot.danger { background: var(--c-red); }
.dot.ok { background: var(--c-green); }

.side-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
}
.theme-btn {
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--fg-dim);
  font-size: 12.5px;
  transition: all .15s var(--ease);
}
.theme-btn:hover { background: var(--bg-hover); color: var(--fg); }
.theme-btn svg { width: 15px; height: 15px; }
.ver { margin-left: auto; font-size: 10.5px; color: var(--fg-faint); font-family: var(--mono); }

/* ---- 主区 ---- */
.main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.pane { display: none; flex-direction: column; height: 100%; min-height: 0; }
.pane.active { display: flex; }

.pane-head {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.pane-head h2 {
  margin: 0; font-size: 18.5px; font-weight: 650;
  letter-spacing: -.02em;
}
.pane-head .sub {
  margin: 3px 0 0; font-size: 12.5px; color: var(--fg-dim);
}
.pane-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }

/* ---- 卡片列表 ---- */
.list-wrap { flex: 1; overflow-y: auto; padding: 20px 28px 40px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
  gap: 13px;
}
.card {
  position: relative;
  padding: 15px 16px 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s var(--ease);
  overflow: hidden;
}
.card::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--cat, transparent);
  opacity: 0; transition: opacity .2s var(--ease);
}
.card:hover {
  border-color: var(--fg-faint);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card:hover::before { opacity: 1; }

.card-top { display: flex; align-items: flex-start; gap: 11px; }
.card-icon {
  width: 34px; height: 34px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px; font-size: 16px;
  background: color-mix(in srgb, var(--cat) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat) 26%, transparent);
}
.card-head { flex: 1; min-width: 0; }
.card-head h3 {
  margin: 0; font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -.01em;
}
.star { color: var(--c-amber); margin-right: 4px; }
.card-user {
  margin: 2px 0 0; font-size: 12px; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--mono);
}
.card-menu {
  width: 26px; height: 26px; flex: none;
  border: none; border-radius: 6px;
  background: transparent; color: var(--fg-faint);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: all .15s var(--ease);
}
.card-menu svg { width: 15px; height: 15px; }
.card:hover .card-menu { opacity: 1; }
.card-menu:hover { background: var(--bg-hover); color: var(--fg); }

.card-tags {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-top: 11px;
}
.card-tags:empty { display: none; }
.tag {
  font-size: 10.5px; padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-hover); color: var(--fg-dim);
  white-space: nowrap;
}
.tag.cat {
  background: color-mix(in srgb, var(--cat) 14%, transparent);
  color: color-mix(in srgb, var(--cat) 78%, var(--fg));
}
.tag.danger { background: rgba(239,68,68,.14); color: var(--c-red); }

.card-notes {
  margin: 9px 0 0; font-size: 12px; color: var(--fg-dim);
  line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  display: flex; align-items: center; gap: 8px;
  margin-top: 11px; padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.card-actions { margin-left: auto; display: flex; gap: 5px; }
.mini {
  height: 25px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--fg-dim);
  font-size: 11.5px;
  transition: all .14s var(--ease);
  white-space: nowrap;
}
.mini:hover { background: var(--bg-hover); color: var(--fg); border-color: var(--fg-faint); }
.mini.danger { color: var(--c-red); }
.mini.danger:hover { background: rgba(239,68,68,.1); }

/* ---- 空状态 ---- */
.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 70px 20px; text-align: center;
}
.empty-icon { font-size: 42px; opacity: .3; margin-bottom: 14px; }
.empty h3 { margin: 0 0 5px; font-size: 15px; font-weight: 600; }
.empty p { margin: 0; font-size: 13px; color: var(--fg-dim); }

/* ---- SQL ---- */
.sql-layout { flex: 1; display: grid; grid-template-columns: 1fr 232px; min-height: 0; }
.sql-main { display: flex; flex-direction: column; min-height: 0; padding: 16px 20px 20px; gap: 12px; }
.sql-bar { display: flex; align-items: center; gap: 8px; flex: none; }
.sql-bar .select { max-width: 260px; height: 34px; }
.sql-spacer { flex: 1; }
.sql-bar .tiny { color: var(--fg-faint); }

.sql-input {
  width: 100%; min-height: 108px; max-height: 40%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 12.8px; line-height: 1.65;
  resize: vertical; outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
  flex: none;
}
.sql-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.sql-result {
  flex: 1; min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  overflow: auto;
}
.sql-placeholder {
  padding: 30px; text-align: center;
  font-size: 12.5px; color: var(--fg-faint);
}
.sql-error {
  padding: 14px 16px; font-size: 12.5px;
  color: var(--c-red); font-family: var(--mono);
  white-space: pre-wrap; word-break: break-word;
}
.sql-meta {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--fg-dim);
  position: sticky; top: 0; background: var(--bg-card); z-index: 2;
}

.table-scroll { overflow: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px; font-family: var(--mono);
}
.data-table th {
  position: sticky; top: 33px;
  text-align: left; padding: 8px 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  font-weight: 600; color: var(--fg-dim);
  white-space: nowrap; z-index: 1;
}
.data-table td {
  padding: 7px 14px;
  border-bottom: 1px solid var(--line-soft);
  max-width: 320px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table tbody tr:hover td { background: var(--bg-hover); }
.null { color: var(--fg-faint); font-style: italic; }

.sql-side { border-left: 1px solid var(--line-soft); overflow-y: auto; padding: 16px 12px; }
.side-block { margin-bottom: 18px; }
.table-list { display: flex; flex-direction: column; gap: 1px; }
.table-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 5px 8px;
  border: none; border-radius: 6px;
  background: transparent; color: var(--fg-dim);
  font-size: 12px; font-family: var(--mono);
  text-align: left;
  transition: all .14s var(--ease);
  overflow: hidden;
}
.table-item .tname {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.table-item em {
  flex: none; font-style: normal;
  font-size: 10px; color: var(--fg-faint);
  background: var(--bg-hover);
  padding: 0 5px; border-radius: 4px;
  min-width: 18px; text-align: center;
}
.table-item:hover { background: var(--bg-hover); color: var(--fg); }
.table-item:hover em { background: var(--bg-elev); }

/* ---- 审计 ---- */
.audit-list { flex: 1; overflow-y: auto; padding: 12px 28px 30px; }
.audit-row {
  display: grid;
  grid-template-columns: 110px 1fr auto auto;
  gap: 14px; align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.audit-action {
  font-weight: 550; font-size: 12px;
  padding: 2px 8px; border-radius: 5px;
  background: var(--bg-hover); color: var(--fg-dim);
  text-align: center; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.audit-action.a-login, .audit-action.a-unlock { background: rgba(16,185,129,.13); color: var(--c-green); }
.audit-action.a-login_fail, .audit-action.a-unlock_fail,
.audit-action.a-sql_blocked, .audit-action.a-sql_error { background: rgba(239,68,68,.13); color: var(--c-red); }
.audit-action.a-entry_create, .audit-action.a-entry_update { background: var(--accent-soft); color: var(--accent); }
.audit-detail {
  color: var(--fg-dim); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 11.5px;
}
.audit-ip { color: var(--fg-faint); font-family: var(--mono); font-size: 11px; }
.audit-time { color: var(--fg-faint); font-size: 11px; white-space: nowrap; }

/* ---- 设置 ---- */
.settings-grid {
  flex: 1; overflow-y: auto;
  padding: 20px 28px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 15px; align-content: start;
}
.card-block {
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-block h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.card-block > .tiny { margin: 0 0 15px; line-height: 1.6; }
.card-block code {
  font-family: var(--mono); font-size: 11px;
  background: var(--bg-hover); padding: 1px 5px; border-radius: 4px;
}

/* ============ 抽屉 ============ */
.drawer-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(2px);
  animation: fadeIn .2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 91;
  width: min(460px, 100vw);
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  box-shadow: -14px 0 46px rgba(0, 0, 0, .34);
  transform: translateX(102%);
  transition: transform .3s var(--ease);
}
.drawer.open { transform: none; }

.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.drawer-head h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }

.drawer-body {
  flex: 1; overflow-y: auto;
  padding: 18px; min-height: 0;
}
.drawer-foot {
  display: flex; align-items: center; gap: 8px;
  padding-top: 16px;
  margin-top: 6px;
  border-top: 1px solid var(--line-soft);
}

.input-row { display: flex; gap: 6px; align-items: center; }
.input-row input { flex: 1; }
.input-row .icon-btn { border: 1px solid var(--line); }

.custom-fields { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.cf-row { display: flex; gap: 6px; align-items: center; }
.cf-row input {
  flex: 1; padding: 7px 10px;
  background: var(--bg-input); border: 1px solid var(--line);
  border-radius: 7px; font-size: 12.5px; outline: none;
}
.cf-row .cf-label { max-width: 120px; }
.cf-row input:focus { border-color: var(--accent); }
.cf-del { font-size: 17px; color: var(--fg-faint); }
.cf-del:hover { color: var(--c-red); background: rgba(239,68,68,.1); }

/* ---- 数据源列表 ---- */
.ds-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 6px; }
.ds-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.ds-item strong { font-size: 13px; font-weight: 550; }
.ds-item p { margin: 1px 0 0; }

/* ============ 提示 ============ */
.toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 300;
  transform: translate(-50%, 14px);
  padding: 9px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 99px;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: all .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(239,68,68,.4); color: var(--c-red); }

.lock-bar {
  position: fixed; left: 50%; bottom: 24px; z-index: 150;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px 10px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--c-amber);
  border-radius: 99px;
  box-shadow: var(--shadow);
  font-size: 12.5px; color: var(--c-amber);
}
.lock-bar button {
  padding: 5px 13px; border: none; border-radius: 99px;
  background: var(--c-amber); color: #1a1206;
  font-size: 12px; font-weight: 600;
}

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar {
    border-right: none; border-bottom: 1px solid var(--line);
    max-height: none;
  }
  .side-head { padding: 10px 12px; }
  .side-nav {
    flex-direction: row; overflow-x: auto;
    padding: 0 8px 8px; gap: 2px;
  }
  .nav-item { width: auto; flex: none; padding: 0 12px; height: 32px; }
  .nav-item em { display: none; }
  .side-filters { display: none !important; }
  .side-search { margin: 0 12px 8px; }
  .side-foot { padding: 6px 12px; }
  .pane-head { padding: 14px 16px 12px; }
  .pane-head h2 { font-size: 16px; }
  .list-wrap, .settings-grid, .audit-list { padding: 14px 16px 30px; }
  .cards { grid-template-columns: 1fr; }
  .sql-layout { grid-template-columns: 1fr; }
  .sql-side { display: none; }
  .drawer { width: 100vw; }
  .audit-row { grid-template-columns: 90px 1fr; gap: 6px 10px; }
  .audit-ip, .audit-time { font-size: 10.5px; }
  .gate-card { padding: 24px 20px; }
}

@media (max-width: 480px) {
  .pane-actions .btn span { display: none; }
  .card-menu { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
