/* ==========================================================================
   nav.foxnan.com — 后台样式
   与前台共用同一套色彩变量，保持视觉连续
   @author 安卿辰  @since 2026-10-19
   ========================================================================== */

/* 色彩变量由 theme.css 统一提供，这里只留后台自己的量 */
:root {
  --radius:     12px;
  --ease:       cubic-bezier(0.22, 0.61, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

/*
 * ⚠️ 必须显式覆盖：浏览器对 [hidden] 只给了 UA 样式的 display:none，
 * 作者样式里的 .modal-mask{display:grid} / .btn{display:inline-flex} 优先级更高，
 * 会把它盖掉 —— 结果就是 hidden 属性完全失效（弹窗关不掉、按钮藏不住）。
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 通用控件 ---------- */

.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.input::placeholder { color: var(--muted); }
.input-sm { height: 34px; width: 170px; font-size: 13px; }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237C837E'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.input-color {
  height: 38px;
  padding: 4px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 15px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: all 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--gold);
  color: var(--on-gold);
  border-color: var(--gold);
}

.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-soft);
}

.btn-ghost:hover {
  background: var(--surface-hi);
  border-color: var(--border-hi);
  color: var(--text);
}

.btn-ghost.danger { color: var(--danger); border-color: rgba(217, 107, 107, 0.3); }
.btn-ghost.danger:hover { background: var(--danger-soft); }

.btn-block { width: 100%; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }

.field { display: block; margin-bottom: 13px; }

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field-label em { color: var(--danger); font-style: normal; }

.field-btn { display: flex; align-items: flex-end; }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}

.check input { accent-color: var(--gold); width: 15px; height: 15px; cursor: pointer; }

.checks { display: flex; flex-wrap: wrap; gap: 18px; margin: 4px 0 2px; }

.hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}

.form-err { min-height: 17px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }
.form-ok  { min-height: 17px; margin: 6px 0 0;  color: var(--teal);   font-size: 12px; }

/* ---------- 登录 ---------- */

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(760px 460px at 50% -10%, var(--gold-soft), transparent 68%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 350px;
  padding: 38px 30px 30px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.9);
  text-align: center;
}

.login-mark {
  font-size: 25px;
  color: var(--gold);
  line-height: 1;
  filter: drop-shadow(0 0 16px var(--gold-soft));
}

.login-title { margin: 14px 0 0; font-size: 19px; font-weight: 600; }
.login-sub { margin: 6px 0 26px; font-size: 12.5px; color: var(--muted); }
.login-card .field { text-align: left; }
.login-err { min-height: 18px; margin: 12px 0 0; color: var(--danger); font-size: 12px; }
.login-foot { margin: 6px 0 0; font-size: 11px; color: var(--muted); }

/* ---------- 布局 ---------- */

.shell {
  display: grid;
  grid-template-columns: 246px 1fr;
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px 14px 16px;
  border-right: 1px solid var(--border);
  background: var(--bg-2);
}

.side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--border);
}

.side-mark { font-size: 15px; color: var(--gold); filter: drop-shadow(0 0 10px var(--gold-soft)); }

.side-title strong { display: block; font-size: 13.5px; font-weight: 600; }
.side-title small { display: block; font-size: 11px; color: var(--muted); letter-spacing: 0.06em; }

.side-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  margin: 0 -4px;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  text-align: left;
  transition: all 0.16s var(--ease);
}

.cat-item:hover { background: var(--surface); color: var(--text); }

.cat-item.active {
  background: var(--gold-soft);
  border-color: var(--gold-soft);
  color: var(--gold);
}

.cat-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-n {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cat-item.active .cat-n { color: var(--gold); opacity: 0.8; }

.side-foot {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.side-stats {
  margin: 12px 0 10px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.side-link {
  display: block;
  width: 100%;
  padding: 7px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  transition: color 0.18s;
}

.side-link:hover { color: var(--text); }
.side-link.danger:hover { color: var(--danger); }

/* ---------- 主区 ---------- */

.main {
  min-width: 0;
  padding: 26px 30px 60px;
}

.main-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.main-title h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.main-desc { margin: 5px 0 0; font-size: 12px; color: var(--muted); }

.main-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* ---------- 表格 ---------- */

.table-wrap { margin-top: 18px; }

.table-head {
  display: grid;
  grid-template-columns: 22px 1fr 118px 150px 128px;
  gap: 12px;
  padding: 0 14px 9px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.rows { margin-top: 4px; }

.row {
  display: grid;
  grid-template-columns: 22px 1fr 118px 150px 128px;
  gap: 12px;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  border-radius: 8px;
  transition: background 0.16s var(--ease);
}

.row:hover { background: var(--surface); }
.row.dragging { opacity: 0.4; }
.row.drag-over { box-shadow: 0 -2px 0 0 var(--gold); }
.row.is-hidden .r-name { opacity: 0.42; }

.r-drag {
  width: 18px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--border-hi);
  cursor: grab;
  font-size: 13px;
  letter-spacing: -1px;
  user-select: none;
}

.r-drag:hover { color: var(--gold); }
.r-drag:active { cursor: grabbing; }

.r-site { display: flex; align-items: center; gap: 10px; min-width: 0; }

.r-ico {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  overflow: hidden;
}

.r-ico img { width: 17px; height: 17px; object-fit: contain; }

.r-meta { min-width: 0; }

.r-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.r-url {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.r-cat {
  font-size: 11.5px;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.r-tag { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.r-op { display: flex; align-items: center; gap: 5px; justify-content: flex-end; }

.pill {
  display: inline-block;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--gold-soft);
  border: 1px solid var(--gold-soft);
  color: var(--gold);
  font-size: 9.5px;
  line-height: 1.7;
  vertical-align: middle;
}

.pill.off { background: var(--danger-soft); border-color: rgba(217, 107, 107, 0.28); color: var(--danger); }

.rows-empty {
  padding: 50px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 弹窗 ---------- */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeIn 0.16s var(--ease);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--border-hi);
  background: var(--bg-2);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.95);
  animation: popIn 0.2s var(--ease);
}

.modal-sm { max-width: 400px; }

@keyframes popIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; }

.modal-x {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  transition: all 0.16s;
}

.modal-x:hover { background: var(--surface); color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.modal-foot .spacer { flex: 1; }

/* 设置弹窗里的分节 */
.set-sec { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.set-sec:last-of-type { border-bottom: 0; padding-bottom: 0; }
.set-h { margin: 0 0 12px; font-size: 12px; font-weight: 600; color: var(--gold); letter-spacing: 0.06em; text-transform: uppercase; }

.data-ops { display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------- 响应式 ---------- */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }

  .side {
    position: static;
    height: auto;
    flex-direction: column;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 14px;
  }

  .side-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 0 4px;
    margin: 0;
    flex: none;
  }

  .cat-item { width: auto; flex-shrink: 0; margin: 0; }
  .side-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 10px; }
  .side-foot .btn-block { width: auto; }
  .side-stats { margin: 0; }
  .side-link { display: inline-block; width: auto; padding: 0; }

  .main { padding: 18px 16px 50px; }

  .table-head { display: none; }

  .row {
    grid-template-columns: 22px 1fr auto;
    grid-template-areas: "drag site op" ". cat cat";
    gap: 6px 10px;
    padding: 11px 8px;
  }

  .r-drag { grid-area: drag; }
  .r-site { grid-area: site; }
  .r-cat  { grid-area: cat; font-size: 11px; }
  .r-tag  { display: none; }
  .r-op   { grid-area: op; }
}

@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
  .main-head { align-items: flex-start; }
  .main-actions { width: 100%; }
  .input-sm { flex: 1; width: auto; }
  .modal { max-height: 92vh; }
}

/* ---------- 设置：配色与背景选择 ---------- */

.pick-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 2px;
}

.pick-row-bg { grid-template-columns: repeat(4, 1fr); }

.pick {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-align: center;
  transition: color 0.2s var(--ease);
}

.pick i {
  display: block;
  width: 100%;
  height: 34px;
  margin-bottom: 6px;
  border-radius: 9px;
  border: 1px solid var(--border-hi);
  /* 同前台：预览固定深底，否则浅色主题下所有背景看起来都一样 */
  --grid-line: rgba(255, 255, 255, 0.3);
  --bamboo-line: rgba(255, 255, 255, 0.36);
  --glow-1: rgba(201, 162, 39, 0.5);
  --glow-2: rgba(111, 168, 152, 0.4);
  --glow-3: rgba(91, 141, 239, 0.35);
  background-color: #121514;
  background-image: var(--bg-layer, none);
  background-size: var(--bg-size, auto);
  background-position: center;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}

.pick:hover i { transform: translateY(-2px); border-color: var(--text-soft); }
.pick:hover { color: var(--text-soft); }

.pick.is-on { color: var(--text); }
.pick.is-on i {
  border-color: var(--gold);
  box-shadow: 0 0 0 1.5px var(--gold);
}

.pick-palette i { height: 30px; }

.pick[data-bg="photo"] i {
  background-image: repeating-linear-gradient(
    45deg, var(--surface-hi) 0 5px, transparent 5px 10px
  );
}

.pick.is-on i::after {
  content: "✓";
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.dim-val {
  color: var(--gold);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.range {
  width: 100%;
  height: 36px;
  margin: 0;
  accent-color: var(--gold);
  background: transparent;
  cursor: pointer;
}

