/* ============================================================
   TX百科 · 管理后台样式
   一套中性灰调色（浅色 / 深色各一份），过渡动画统一在下方。
   变量前缀 a- ，避免和 style.css 的 --bg/--fg 打架。
   ============================================================ */

:root {
  --a-bg:        #f4f5f7;
  --a-card:      #ffffff;
  --a-line:      #e8eaee;
  --a-line-soft: #f0f1f4;
  --a-text:      #1f2329;
  --a-sub:       #6b7280;
  --a-faint:     #9ba1aa;
  --a-brand:     #22262c;
  --a-brand-fg:  #ffffff;
  --a-side:      #1d2126;
  --a-side-fg:   #c3c8d0;
  --a-side-on:   #2b3138;
  --a-danger:    #d94a4f;
  --a-danger-bg: #fdf4f4;
  --a-shadow:    0 1px 2px rgba(20, 24, 30, .04), 0 8px 24px rgba(20, 24, 30, .05);
  --a-ease:      cubic-bezier(.22, .61, .36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --a-bg:        #101316;
    --a-card:      #171b20;
    --a-line:      #252a31;
    --a-line-soft: #1e2329;
    --a-text:      #e6e9ed;
    --a-sub:       #98a0aa;
    --a-faint:     #78808a;
    --a-brand:     #e6e9ed;
    --a-brand-fg:  #14181c;
    --a-side:      #0b0e11;
    --a-side-fg:   #b9c0c8;
    --a-side-on:   #1c2127;
    --a-danger:    #ff6f74;
    --a-danger-bg: #2a1b1d;
    --a-shadow:    none;
  }
}

/* ---------------- 基础 ---------------- */
/* [hidden] 必须真的隐藏：.gate / .app 这类类都自带 display，
   会盖掉浏览器默认的 [hidden]{display:none} —— 结果就是登录页和后台同时出现 */
[hidden] { display: none !important; }

/* ---------------- 侧栏分组 / 抽屉遮罩 ---------------- */
.nav-group > a { display: flex; align-items: center; }
.nav a .caret {
  margin-left: auto; font-size: 14px; font-weight: 700;
  opacity: .45; transition: transform .18s var(--a-ease);
}
.nav-group.open > a .caret { transform: rotate(90deg); }
.nav-sub { display: block; margin: 2px 0 2px 6px; }
.nav-sub a { font-size: 13px; opacity: .82; padding-left: 38px !important; }
.nav-sub a::before { display: none !important; }
.scrim { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(8, 10, 14, .45); }
.app.nav-open .scrim { display: block; }
@media (min-width: 901px) { .scrim { display: none !important; } }

/* ---------------- 分析页 ---------------- */
.bars { display: flex; align-items: stretch; gap: 6px; height: 140px; padding: 6px 2px 0; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; gap: 4px; }
.bars .bar i { display: block; width: 100%; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--a-text), var(--a-sub)); opacity: .78; }
.bars .bar b { font-size: 10px; color: var(--a-faint); font-weight: 500; }
.bars .bar em { font-size: 10.5px; color: var(--a-faint); font-style: normal; }

/* ---------------- 链接解析卡 ---------------- */
.parse-card {
  background: var(--a-card); border: 1px solid var(--a-line);
  border-radius: 12px; padding: 12px 14px 2px; margin: 0 0 14px;
}
.parse-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.parse-head b { font-size: 13.5px; }
.parse-head em { font-style: normal; font-size: 11.5px; color: var(--a-faint); }

body.admin {
  background: var(--a-bg);
  color: var(--a-text);
  -webkit-font-smoothing: antialiased;
}

@keyframes aRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes aFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes aToast { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------- 登录页 ---------------- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--a-bg);
}
.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--a-card);
  border: 1px solid var(--a-line);
  border-radius: 16px;
  padding: 26px 24px 22px;
  box-shadow: var(--a-shadow);
  display: flex;
  flex-direction: column;
  animation: aRise .32s var(--a-ease);
}
.gate-mark {
  width: 42px; height: 42px;
  margin: 0 auto 14px;
  border-radius: 12px;
}
.gate-card h1 {
  margin: 0 0 6px;
  font-size: 17px;
  text-align: center;
  color: var(--a-text);
  font-weight: 600;
}
.gate-card .sub {
  margin: 0 0 20px;
  font-size: 12.5px;
  color: var(--a-sub);
  text-align: center;
}

/* ---------------- 骨架 ---------------- */
.app { min-height: 100vh; display: flex; }

.sidebar {
  width: 226px;
  flex: none;
  background: var(--a-side);
  color: var(--a-side-fg);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side-brand { margin: 2px 6px 18px; }
.side-brand .brand-text {
  color: var(--a-text);
  filter: none;
  font-size: 15px;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
}
.side-brand .brand-text { color: #fff; }
.side-brand .brand-text em {
  font-style: normal;
  font-size: 10.5px;
  color: #8b919b;
  letter-spacing: .4px;
  margin-top: 3px;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--a-side-fg);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  transition: background .16s var(--a-ease), color .16s var(--a-ease);
}
.nav a i {
  font-style: normal;
  width: 16px;
  text-align: center;
  font-size: 13px;
  color: #7e848e;
  transition: color .16s;
}
.nav a::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 3px; height: 0;
  background: #fff;
  border-radius: 0 3px 3px 0;
  transform: translateY(-50%);
  transition: height .2s var(--a-ease);
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.on { background: var(--a-side-on); color: #fff; }
.nav a.on i { color: #fff; }
.nav a.on::before { height: 15px; }

.side-foot { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.side-foot .ghost { background: transparent; color: var(--a-side-fg); border-color: rgba(255, 255, 255, .14); }
.side-foot .ghost:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.side-hint { margin: 4px 4px 0; font-size: 11px; color: #6e747e; text-align: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar2 {
  height: 58px;
  flex: none;
  background: var(--a-card);
  border-bottom: 1px solid var(--a-line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar2 .tt h1 { margin: 0; font-size: 15.5px; color: var(--a-text); font-weight: 600; }
.topbar2 .tt p { margin: 2px 0 0; font-size: 11.5px; color: var(--a-sub); }
.topbar2 .spacer { flex: 1; }
.acct { font-size: 12px; color: var(--a-sub); }
.icon-btn {
  display: none;
  width: 34px; height: 34px;
  border-radius: 9px;
  border: 1px solid var(--a-line);
  background: var(--a-card);
  color: var(--a-text);
  font-size: 16px;
  cursor: pointer;
}

/* ---------------- 视图 / 卡片 ---------------- */
.view {
  padding: 20px 22px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: aRise .26s var(--a-ease);
}
.view[hidden] { display: none; }

.card {
  background: var(--a-card);
  border: 1px solid var(--a-line);
  border-radius: 14px;
  padding: 16px 18px;
  transition: border-color .18s, box-shadow .18s;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 14px; color: var(--a-text); font-weight: 600; }
.card-head .badge {
  font-size: 11px;
  color: var(--a-sub);
  background: var(--a-line-soft);
  border-radius: 20px;
  padding: 3px 10px;
}
.card .sub { margin: 0 0 12px; font-size: 12.5px; line-height: 1.7; color: var(--a-sub); }
.card .sub:last-child { margin-bottom: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  background: var(--a-card);
  border: 1px solid var(--a-line);
  border-radius: 14px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .18s var(--a-ease), box-shadow .18s, border-color .18s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--a-shadow); border-color: transparent; }
.stat b { font-size: 25px; line-height: 1; color: var(--a-text); font-weight: 600; }
.stat span { font-size: 12px; color: var(--a-sub); }

.quick { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------- 按钮 ---------------- */
button, .btn { font: inherit; }
button.primary, .primary {
  background: var(--a-brand);
  color: var(--a-brand-fg);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background .16s, transform .12s var(--a-ease), box-shadow .16s;
}
button.ghost, .ghost {
  background: var(--a-card);
  color: var(--a-text);
  border: 1px solid var(--a-line);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  transition: background .16s, border-color .16s, color .16s, transform .12s var(--a-ease);
}
button.danger, .danger {
  background: var(--a-card);
  color: var(--a-danger);
  border: 1px solid var(--a-danger);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background .16s, transform .12s var(--a-ease);
}
button.primary:hover { opacity: .9; }
button.ghost:hover { background: var(--a-line-soft); }
button.danger:hover { background: var(--a-danger-bg); }
button:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.sm { padding: 6px 10px; font-size: 12px; }
.block { display: block; width: 100%; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.actions-msg { font-size: 12px; color: var(--a-sub); }

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: var(--a-sub); }
.field > span em { font-style: normal; color: var(--a-faint); }
.field input, .field textarea, .field select,
input[type="text"], input[type="password"], input[type="number"], input[type="search"], textarea {
  border: 1px solid var(--a-line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--a-text);
  background: var(--a-card);
  width: 100%;
  font-family: inherit;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.field textarea, textarea { resize: vertical; line-height: 1.65; }
input:focus, textarea:focus {
  outline: 0;
  border-color: var(--a-faint);
  box-shadow: 0 0 0 3px rgba(130, 140, 155, .16);
}
input::placeholder, textarea::placeholder { color: var(--a-faint); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.row-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--a-sub);
}
.row-inline label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.cfg-group {
  margin: 20px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--a-line);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--a-sub);
  letter-spacing: .3px;
}

.err { color: var(--a-danger); font-size: 12.5px; margin: 10px 0 0; text-align: center; }
.mono { font-family: var(--mono, ui-monospace, Menlo, Consolas, monospace); font-size: 12px; }

/* ---------------- 条目管理：两栏 ---------------- */
#view-entries {
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 20px 22px 48px;
  animation: aRise .26s var(--a-ease);
}
#view-entries[hidden] { display: none; }

.side {
  background: var(--a-card);
  border: 1px solid var(--a-line);
  border-radius: 14px;
  padding: 12px;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 94px);
  display: flex;
  flex-direction: column;
}
.side-head { display: flex; gap: 8px; }
.side-head input { flex: 1; }
.side-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--a-sub);
  padding: 10px 2px 6px;
}
.side-tools { display: flex; gap: 8px; padding: 0 0 8px; }
.side-foot-row {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--a-line);
  margin-top: 8px;
}

.list { overflow-y: auto; flex: 1; margin: 0 -4px; }
.item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .14s;
}
.item:hover { background: var(--a-line-soft); }
.item.on { background: var(--a-line-soft); }
.item input[type="checkbox"] { margin-top: 3px; flex: none; accent-color: var(--a-brand); }
.item .it-body { min-width: 0; flex: 1; }
.item .it-title {
  font-size: 13.5px;
  color: var(--a-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item .it-sub {
  font-size: 11.5px;
  color: var(--a-sub);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item .it-id {
  font-size: 10.5px;
  color: var(--a-faint);
  font-family: var(--mono);
  margin-top: 2px;
}

.editor {
  background: var(--a-card);
  border: 1px solid var(--a-line);
  border-radius: 14px;
  padding: 16px 18px 18px;
}
.editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.editor-head h2 { margin: 0; font-size: 14px; color: var(--a-text); font-weight: 600; }
.badge {
  font-size: 11px;
  color: var(--a-sub);
  background: var(--a-line-soft);
  border-radius: 20px;
  padding: 3px 10px;
}

/* ---------------- 日志 ---------------- */
.log-list { display: flex; flex-direction: column; }
.log-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px dashed var(--a-line);
  font-size: 12.5px;
  animation: aFade .22s;
}
.log-row:last-child { border-bottom: 0; }
.log-row .lg-time { color: var(--a-faint); font-size: 11.5px; flex: none; width: 128px; font-family: var(--mono); }
.log-row .lg-act {
  flex: none;
  background: var(--a-line-soft);
  color: var(--a-text);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11.5px;
}
.log-row .lg-detail { color: var(--a-sub); min-width: 0; flex: 1; word-break: break-all; }
.log-empty { font-size: 12.5px; color: var(--a-sub); padding: 10px 2px; }

/* ---------------- 系统信息表 ---------------- */
.kv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv-table th {
  text-align: left;
  width: 92px;
  vertical-align: top;
  padding: 9px 10px 9px 0;
  color: var(--a-sub);
  font-weight: 500;
  white-space: nowrap;
}
.kv-table td { padding: 9px 0; color: var(--a-text); line-height: 1.7; word-break: break-all; }
.kv-table tr + tr th, .kv-table tr + tr td { border-top: 1px solid var(--a-line-soft); }

/* ---------------- 危险区 ---------------- */
.danger-card { border-color: rgba(217, 74, 79, .35); }
.danger-row { display: flex; align-items: center; gap: 16px; padding: 12px 0; }
.danger-row + .danger-row { border-top: 1px solid var(--a-line-soft); }
.danger-row > div { flex: 1; }
.danger-row b { font-size: 13.5px; color: var(--a-text); font-weight: 600; }
.danger-row p { margin: 4px 0 0; font-size: 12px; color: var(--a-sub); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(28, 31, 36, .95);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 22px;
  z-index: 99;
  max-width: 80vw;
  animation: aToast .22s var(--a-ease);
}
@media (prefers-color-scheme: dark) {
  .toast { background: #e6e9ed; color: #14181c; }
}

/* ---------------- 窄屏：侧栏变抽屉 ---------------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .22s var(--a-ease);
    box-shadow: 0 0 40px rgba(0, 0, 0, .3);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(18, 20, 24, .45);
    z-index: 30;
    animation: aFade .18s;
  }
  .icon-btn { display: block; }
  #view-entries { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row2, .row3 { grid-template-columns: minmax(0, 1fr); }
  .view { padding: 14px 14px 44px; }
  #view-entries { padding: 14px 14px 44px; }
  .topbar2 { padding: 0 14px; }
}

/* 减少动态偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* ---------------- 骨架占位（加载中，替掉原来的 —） ---------------- */
.sk, .sk-row {
  display: inline-block;
  width: 52px;
  height: 13px;
  border-radius: 7px;
  background: linear-gradient(90deg,
              var(--a-line-soft) 0%, var(--a-line) 50%, var(--a-line-soft) 100%);
  background-size: 220% 100%;
  animation: aShimmer 1.2s linear infinite;
}
.sk-row { display: block; width: 100%; height: 14px; margin: 9px 0; }
@keyframes aShimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
