/* ============================================================
   NEXUS 控制台样式
   ============================================================ */
:root {
  --bg: #05070d;
  --panel: #0a0f1a;
  --panel-2: #0d1422;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(0, 229, 255, 0.35);
  --text: #e7f0ff;
  --muted: #7b8ba5;
  --cyan: #00e5ff;
  --purple: #7c4dff;
  --green: #2ee6a8;
  --red: #ff5570;
  --radius: 14px;
  --font-tech: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
  --font: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* 关键：确保 hidden 属性优先级高于 display:grid/flex 等作者样式 */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.aura {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 560px at 8% -12%, rgba(0, 229, 255, 0.14), transparent 60%),
    radial-gradient(800px 520px at 102% 4%, rgba(124, 77, 255, 0.16), transparent 58%),
    radial-gradient(700px 460px at 60% 112%, rgba(0, 229, 255, 0.06), transparent 60%);
}
.grid-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 200, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 200, 255, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 80%);
}

::selection { background: rgba(0, 229, 255, 0.3); color: #fff; }

/* ---------------- 通用控件 ---------------- */
input, select, textarea, button { font-family: inherit; font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--line-strong); color: var(--cyan); background: rgba(0, 229, 255, 0.08); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  border: 0;
  color: #04121b;
  font-weight: 600;
  background: linear-gradient(120deg, var(--cyan), #4aa8ff 60%, var(--purple));
  box-shadow: 0 8px 24px -12px rgba(0, 229, 255, 0.9);
}
.btn.primary:hover { color: #04121b; filter: brightness(1.06); transform: translateY(-1px); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn.danger { color: var(--red); border-color: rgba(255, 85, 112, 0.3); }
.btn.danger:hover { background: rgba(255, 85, 112, 0.1); border-color: var(--red); color: var(--red); }
.btn.block { width: 100%; height: 42px; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }

input[type='text'], input[type='password'], input[type='search'], input[type='url'], select, textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
select { appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%237b8ba5' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.1);
  background: rgba(0, 229, 255, 0.03);
}
input::placeholder { color: #54627a; }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 386px;
  padding: 38px 32px 30px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(12, 18, 30, 0.72);
  backdrop-filter: blur(22px);
  box-shadow: 0 40px 100px -40px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(0, 229, 255, 0.06) inset;
  text-align: center;
  animation: pop 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(0.98); } }
.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  font-family: var(--font-tech);
  font-weight: 900;
  font-size: 26px;
  color: #041018;
  background: linear-gradient(140deg, var(--cyan), var(--purple));
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0% 50%);
  box-shadow: 0 0 40px -6px rgba(0, 229, 255, 0.85);
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; letter-spacing: 0.04em; }
.login-sub { margin: 0 0 26px; font-size: 12px; color: var(--muted); letter-spacing: 0.1em; }
.login-card label { display: block; text-align: left; margin-bottom: 14px; }
.login-card label span { display: block; margin-bottom: 7px; font-size: 12px; color: var(--muted); }
.login-back { display: inline-block; margin-top: 18px; font-size: 12px; color: var(--muted); text-decoration: none; transition: color 0.2s; }
.login-back:hover { color: var(--cyan); }
.form-err { min-height: 16px; margin: 10px 0 0; font-size: 12px; color: var(--red); }

/* ---------------- 主框架 ---------------- */
.app {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: rgba(8, 12, 20, 0.78);
  backdrop-filter: blur(18px);
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.side-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-family: var(--font-tech); font-weight: 900; font-size: 16px;
  color: #04121b;
  background: linear-gradient(140deg, var(--cyan), var(--purple));
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0% 50%);
}
.side-brand strong { display: block; font-family: var(--font-tech); font-size: 14px; letter-spacing: 0.18em; }
.side-brand em { font-style: normal; font-size: 9px; letter-spacing: 0.22em; color: var(--muted); }

.side-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.side-nav button {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}
.side-nav button i { font-style: normal; font-size: 14px; width: 16px; text-align: center; opacity: 0.85; }
.side-nav button:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.side-nav button.active {
  color: var(--cyan);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.14), rgba(0, 229, 255, 0.02));
  border-color: rgba(0, 229, 255, 0.22);
  box-shadow: inset 2px 0 0 var(--cyan);
}

.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 8px; padding: 0 10px 10px; font-size: 12.5px; color: var(--muted); }
.side-user i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.logout {
  width: 100%; height: 36px; border-radius: 9px;
  border: 1px solid var(--line);
  background: none; color: var(--muted);
  cursor: pointer; font-size: 12.5px; transition: all 0.2s;
}
.logout:hover { color: var(--red); border-color: rgba(255, 85, 112, 0.4); background: rgba(255, 85, 112, 0.07); }

/* ---------------- 内容区 ---------------- */
.content { padding: 26px clamp(18px, 3vw, 40px) 60px; max-width: 1180px; }
.content-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding-bottom: 20px; margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.content-head h1 { margin: 0 0 5px; font-size: 21px; font-weight: 600; letter-spacing: 0.02em; }
.content-head p { margin: 0; font-size: 12.5px; color: var(--muted); }
.head-actions { display: flex; gap: 8px; }
.head-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.head-tools select { width: 140px; }
.head-tools input { width: 180px; }

.panel {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0.008));
  margin-bottom: 18px;
  overflow: hidden;
}
.panel.narrow { max-width: 640px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.014);
}
.panel-head h2 { margin: 0; font-size: 13.5px; font-weight: 600; letter-spacing: 0.04em; }
.panel-body { padding: 18px; }
.panel-foot { padding: 15px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.hint { margin: 0 0 14px; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); font-size: 12.5px; }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  position: relative;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(0, 229, 255, 0.05), rgba(255, 255, 255, 0.012));
  overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; top: -40px; right: -40px; width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.18), transparent 65%);
}
.stat-label { font-size: 11.5px; color: var(--muted); letter-spacing: 0.08em; }
.stat-card strong {
  display: block; margin: 10px 0 4px;
  font-family: var(--font-tech); font-size: 30px; font-weight: 700;
  background: linear-gradient(120deg, #fff, var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-card strong.ok { font-size: 22px; color: var(--green); background: none; -webkit-text-fill-color: var(--green); }
.stat-card small { font-size: 11px; color: var(--muted); }

.tips { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.9; }
.tips b { color: var(--cyan); font-weight: 600; }
.tips li::marker { color: rgba(0, 229, 255, 0.5); }

/* ---------------- 分类列表 ---------------- */
.cat-list { display: flex; flex-direction: column; gap: 8px; }
.cat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.022);
  cursor: grab;
  transition: all 0.18s;
}
.cat-row:hover { border-color: rgba(0, 229, 255, 0.3); background: rgba(0, 229, 255, 0.04); }
.cat-row.dragging { opacity: 0.4; }
.cat-row.drop-target { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.18); }
.drag-dots { color: var(--muted); font-size: 14px; letter-spacing: -1px; cursor: grab; }
.cat-icon-chip {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(140deg, rgba(0, 229, 255, 0.22), rgba(124, 77, 255, 0.22));
  font-size: 13px;
}
.cat-name { flex: 1; font-size: 13.5px; font-weight: 500; }
.cat-count { font-size: 11.5px; color: var(--muted); font-family: var(--font-tech); }
.row-actions { display: flex; gap: 6px; }
.icon-action {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--line); background: none;
  color: var(--muted); cursor: pointer; font-size: 12px; transition: all 0.18s;
}
.icon-action:hover { color: var(--cyan); border-color: var(--line-strong); }
.icon-action.del:hover { color: var(--red); border-color: rgba(255, 85, 112, 0.45); }

/* ---------------- 站点表格 ---------------- */
.site-table { display: flex; flex-direction: column; gap: 7px; }
.site-row {
  display: grid;
  grid-template-columns: 22px 26px 34px minmax(110px, 1.1fr) minmax(150px, 2fr) 100px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.18s;
  cursor: grab;
}
.site-row.selected { border-color: rgba(0, 229, 255, 0.4); background: rgba(0, 229, 255, 0.06); }
.site-row:hover { border-color: rgba(0, 229, 255, 0.28); background: rgba(0, 229, 255, 0.035); }
.site-row.dragging { opacity: 0.4; }
.site-row.drop-target { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.16); }
.site-fav {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-family: var(--font-tech); font-size: 12px; color: #04121b; font-weight: 700;
  background: linear-gradient(140deg, var(--cyan), var(--purple));
  overflow: hidden;
}
.site-fav img { width: 100%; height: 100%; object-fit: cover; }
.site-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-url { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-cat { font-size: 11px; color: var(--cyan); border: 1px solid rgba(0, 229, 255, 0.22); border-radius: 6px; padding: 3px 7px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-tags { display: flex; gap: 4px; flex-wrap: wrap; overflow: hidden; }
.site-tags span { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }

.row-chk { width: 15px; height: 15px; accent-color: #00e5ff; cursor: pointer; margin: 0; }
.chk-all { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.chk-all input { width: 15px; height: 15px; accent-color: #00e5ff; cursor: pointer; }

/* ---------------- 表单 ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 12px; color: var(--muted); }
.field.span2 { grid-column: span 2; }
.engine-list { display: flex; flex-direction: column; gap: 10px; }
.engine-item { display: grid; grid-template-columns: 180px 1fr 34px; gap: 10px; align-items: center; }

.switch-field { flex-direction: row; align-items: center; justify-content: space-between; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line);
  transition: all 0.25s; cursor: pointer;
}
.switch i::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #8fa3bd; transition: all 0.25s;
}
.switch input:checked + i { background: rgba(0, 229, 255, 0.3); border-color: var(--cyan); }
.switch input:checked + i::after { transform: translateX(20px); background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }

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

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(2, 5, 10, 0.72);
  backdrop-filter: blur(6px);
  animation: fade 0.2s both;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #0c1322, #080d17);
  box-shadow: 0 40px 100px -30px #000, 0 0 0 1px rgba(0, 229, 255, 0.07) inset;
  animation: pop 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-close { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: none; color: var(--muted); cursor: pointer; font-size: 17px; line-height: 1; }
.modal-close:hover { color: var(--red); border-color: rgba(255, 85, 112, 0.4); }
.modal-body { padding: 20px; overflow-y: auto; display: grid; gap: 14px; }
.modal-body .field { gap: 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translate(-50%, 16px);
  z-index: 300;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(10, 16, 26, 0.96);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 20px 50px -20px #000;
  opacity: 0; pointer-events: none;
  transition: all 0.28s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255, 85, 112, 0.5); color: #ff8fa0; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 10px; padding: 12px 14px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .side-brand { padding: 0; flex-shrink: 0; }
  .side-brand div { display: none; }
  .side-nav { flex-direction: row; margin: 0; gap: 4px; }
  .side-nav button { width: auto; height: 34px; padding: 0 11px; white-space: nowrap; }
  .side-nav button i { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-shrink: 0; }
  .side-user { display: none; }
  .logout { width: auto; padding: 0 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span2 { grid-column: span 1; }
  .site-row { grid-template-columns: 22px 26px 30px 1fr auto; }
  .site-url, .site-cat, .site-tags { display: none; }
  .engine-item { grid-template-columns: 1fr 34px; }
  .engine-item input:first-child { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
