* { box-sizing: border-box; }
:root {
  --bg: #0a0c11; --panel: #12151d; --panel-2: #171b26; --line: rgba(255,255,255,.09);
  --txt: #e8ecf3; --txt-2: #93a0b4; --accent: #ff3b5c; --accent-2: #ff8a3d;
  --green: #24c98a; --blue: #3d8bff; --radius: 12px;
}
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--txt); font-size: 14px;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 80% -10%, rgba(255,59,92,.16), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.login-card h1 { font-size: 21px; margin: 0 0 6px; }
.login-sub { color: var(--txt-2); font-size: 13px; margin: 0 0 22px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--txt-2); }
.login-card input { width: 100%; margin-top: 6px; }
.login-tip { color: #6d768a; font-size: 12px; text-align: center; margin: 14px 0 0; }
.btn { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; border: 0; padding: 9px 18px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; padding: 11px; }
.btn.ghost { background: rgba(255,255,255,.07); border: 1px solid var(--line); color: var(--txt); font-weight: 500; }
.btn.ghost:hover { border-color: rgba(255,59,92,.5); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { background: linear-gradient(120deg, #e0364f, #b32036); }
.btn.green { background: linear-gradient(120deg, #16a86b, #24c98a); }

input, select, textarea {
  background: #0d1017; border: 1px solid var(--line); border-radius: 9px;
  color: var(--txt); padding: 8px 11px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: rgba(255,59,92,.55); }
textarea { resize: vertical; min-height: 90px; line-height: 1.7; font-family: inherit; }
label.fld { display: block; margin-bottom: 12px; font-size: 13px; color: var(--txt-2); }
label.fld > input, label.fld > select, label.fld > textarea { margin-top: 6px; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 18px 14px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--line); }
#sideNav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
#sideNav a { padding: 10px 13px; border-radius: 9px; color: var(--txt-2); display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
#sideNav a:hover { background: rgba(255,255,255,.05); color: var(--txt); }
#sideNav a.on { background: rgba(255,59,92,.14); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.badge { font-size: 10.5px; background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; padding: 1px 6px; border-radius: 999px; font-style: normal; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 12px 18px; display: flex; flex-direction: column; gap: 9px; font-size: 13px; color: var(--txt-2); }
.sidebar-foot a:hover { color: var(--accent); }
.content { flex: 1; padding: 24px 28px 60px; min-width: 0; }
.loading { color: var(--txt-2); padding: 40px; text-align: center; }

h2.page-title { font-size: 19px; margin: 0 0 4px; }
.page-sub { color: var(--txt-2); font-size: 13px; margin: 0 0 20px; }

/* 卡片 & 统计 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { color: var(--txt-2); font-size: 12.5px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 6px; background: linear-gradient(120deg,#fff,#ffb1c0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.panel h3 .hint { font-weight: 400; color: var(--txt-2); font-size: 12.5px; margin-left: 8px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1; min-width: 140px; }
.row > label.fld { margin-bottom: 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.spacer { flex: 1; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--txt-2); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
tbody tr:hover { background: rgba(255,255,255,.03); }
td.actions { white-space: nowrap; }
td.actions .btn { margin-right: 6px; }
.thumb { width: 42px; height: 56px; object-fit: cover; border-radius: 6px; background: #0d1017; }
.muted { color: var(--txt-2); }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.pill { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--txt-2); white-space: nowrap; }
.pill.ok { background: rgba(36,201,138,.16); color: #46dea4; }
.pill.new { background: rgba(61,139,255,.16); color: #74aaff; }
.pill.off { background: rgba(255,255,255,.06); color: #6d768a; }
.empty-box { color: var(--txt-2); text-align: center; padding: 36px 0; }

/* 分页 */
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 18px; font-size: 13px; color: var(--txt-2); }
.pager button { background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--txt); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* 采集 */
.collect-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .collect-layout { grid-template-columns: 1fr; } }
.selectable tr.sel { background: rgba(255,59,92,.1); }
.check-all { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--txt-2); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
.result-box { background: #0d1017; border: 1px solid var(--line); border-radius: 9px; padding: 12px; font-size: 13px; line-height: 1.9; color: var(--txt-2); max-height: 220px; overflow: auto; white-space: pre-wrap; }
.result-box b { color: #fff; }
.log-list { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.log-item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; background: var(--panel-2); border-radius: 9px; }
.log-item .t { color: var(--txt-2); font-size: 12px; }

/* 弹窗 */
.modal-mask { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(4,6,10,.72); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 680px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 30px 70px rgba(0,0,0,.6); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.close-x { background: transparent; border: 0; color: var(--txt-2); font-size: 20px; cursor: pointer; line-height: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

/* toast */
#toastRoot { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: rgba(22,26,36,.98); border: 1px solid var(--line); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.toast.err { border-color: rgba(255,80,110,.6); }
.toast.ok { border-color: rgba(36,201,138,.6); }

/* ==================== 手机 / 平板自适应 ==================== */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 50;
    flex-direction: row; align-items: center; gap: 0;
    overflow-x: auto; background: var(--panel);
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { border: 0; border-right: 1px solid var(--line); padding: 10px 12px; font-size: 15px; white-space: nowrap; }
  #sideNav { flex-direction: row; flex: 1 0 auto; flex-wrap: nowrap; gap: 4px; padding: 6px; overflow-x: auto; }
  #sideNav a { padding: 8px 12px; font-size: 13px; white-space: nowrap; }
  #sideNav a.on { box-shadow: inset 0 -2px 0 var(--accent); }
  .sidebar-foot { border: 0; border-left: 1px solid var(--line); flex-direction: row; padding: 8px 12px; white-space: nowrap; }
  .content { padding: 14px 12px calc(40px + env(safe-area-inset-bottom, 0px)); }

  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .v { font-size: 20px; }
  .page-title { font-size: 17px; }
  .page-sub { font-size: 12.5px; }

  /* 表格横向滚动，避免撑破页面 */
  .panel { padding: 14px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .panel > table { min-width: 620px; }
  th, td { padding: 9px 8px; white-space: nowrap; }
  .ellipsis { max-width: 180px; }

  .toolbar { gap: 8px; }
  .toolbar .grow { flex: 1 0 100%; min-width: 0; }
  .collect-layout { grid-template-columns: 1fr; }
  .row > label.fld { flex: 1 0 100%; }
  .grid2 { grid-template-columns: 1fr; }

  .modal-mask { padding: 10px; }
  .modal { max-width: 100%; max-height: 92vh; }
  .modal-head { padding: 13px 15px; }
  .modal-body { padding: 14px 15px; }
  .modal-foot { padding: 12px 15px; }
  .modal-foot .btn { flex: 1; }

  .log-item { flex-direction: column; gap: 4px; }
  .result-box { max-height: 260px; }
  .login-card { padding: 24px 20px; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
  .thumb { width: 36px; height: 48px; }
  .btn.sm { padding: 6px 10px; }
}