/* =========================================================
   QR 跳转管理台 — 浅色商业风格
   规则：仅实色填充；禁止紫色 / 深色主题 / 任何渐变
   ========================================================= */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f1f4f6;
  --line: #e2e7ec;
  --line-strong: #cdd5dd;
  --ink: #1b232d;
  --ink-2: #5a6672;
  --ink-3: #8b959f;
  --brand: #136a86;
  --brand-hover: #0f566c;
  --brand-soft: #e8f1f5;
  --ok: #17795a;
  --ok-soft: #e6f2ec;
  --warn: #92660f;
  --warn-soft: #fbf2dc;
  --danger: #b23c2b;
  --danger-soft: #fbeae7;
  --radius: 8px;
  --shadow-1: 0 1px 2px rgba(21, 34, 48, 0.05);
  --shadow-2: 0 2px 8px rgba(21, 34, 48, 0.07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover { background: var(--surface-3); }
.btn:active { background: #e9edf0; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-primary:active { background: #0c4959; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

.btn-danger {
  background: var(--surface);
  border-color: #e3c8c3;
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------------- inputs ---------------- */

.field { display: block; margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input::placeholder { color: var(--ink-3); }
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(19, 106, 134, 0.12);
}
textarea.input { height: auto; padding: 9px 11px; resize: vertical; min-height: 76px; }
.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
}

/* ---------------- login ---------------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 384px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px 30px 28px;
  box-shadow: var(--shadow-2);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 22px;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

.auth-brand-text strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}
.auth-brand-text span { display: block; font-size: 12px; color: var(--ink-3); }

.auth-title { font-size: 18px; font-weight: 650; margin: 0 0 4px; }
.auth-sub { font-size: 13px; color: var(--ink-2); margin: 0 0 22px; }

.alert {
  display: none;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert.show { display: block; }
.alert-error { background: var(--danger-soft); border-color: #eccfc9; color: var(--danger); }
.alert-ok { background: var(--ok-soft); border-color: #cbe3d8; color: var(--ok); }

.auth-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
}

/* ---------------- app shell ---------------- */

.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 226px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand-text strong { display: block; font-size: 14px; font-weight: 650; }
.sidebar-brand-text span { display: block; font-size: 11.5px; color: var(--ink-3); }

.nav { padding: 12px 10px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 11px;
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  border-left: 2px solid transparent;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-left-color: var(--brand);
  font-weight: 600;
}
.nav-item svg { flex: 0 0 auto; }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.who { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who b { color: var(--ink); font-weight: 600; }

.main {
  margin-left: 226px;
  padding: 22px 26px 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 19px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.topbar .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }

.search {
  position: relative;
}
.search .input { width: 240px; height: 34px; padding-left: 32px; }
.search svg { position: absolute; left: 10px; top: 9px; color: var(--ink-3); }
/* 去掉 WebKit 原生搜索清除按钮，保持统一外观 */
.search input[type="search"]::-webkit-search-decoration,
.search input[type="search"]::-webkit-search-cancel-button,
.search input[type="search"]::-webkit-search-results-button {
  -webkit-appearance: none;
  appearance: none;
}

/* ---------------- cards ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 14px; font-weight: 650; margin: 0; }
.card-body { padding: 18px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 15px 17px;
  box-shadow: var(--shadow-1);
}
.stat-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.stat-value {
  font-size: 26px;
  font-weight: 650;
  line-height: 1.2;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-hint { font-size: 12px; color: var(--ink-3); margin-top: 3px; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* 设置页：左「修改密码」右「系统信息」 */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 1000px) {
  .settings-grid { grid-template-columns: 1fr; }
}

/* ---------------- chart ---------------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 148px;
  padding: 4px 2px 0;
}
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.chart-bar {
  width: 100%;
  min-height: 3px;
  background: var(--brand);
  border-radius: 3px 3px 0 0;
  transition: opacity 0.12s ease;
}
.chart-bar:hover { opacity: 0.8; }
.chart-label { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart-value { font-size: 11.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------- table ---------------- */

.table-wrap { overflow-x: auto; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  white-space: nowrap;
}
.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }

.thumb {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: var(--surface-3);
  display: block;
}
.thumb-ph {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-size: 10px;
}

.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }

.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  word-break: break-all;
}

.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: #cfe5da; }
.badge-off { background: var(--surface-3); color: var(--ink-2); border-color: var(--line); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #ecdcb6; }

.row-actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty svg { color: var(--line-strong); margin-bottom: 10px; }
.empty p { margin: 0 0 4px; font-size: 14px; color: var(--ink-2); font-weight: 500; }
.empty span { font-size: 12.5px; }

/* ---------------- dropzone ---------------- */

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 26px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .dz-title { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-top: 8px; }
.dropzone .dz-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.dropzone svg { color: var(--brand); }

/* ---------------- drawer ---------------- */

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(27, 35, 45, 0.28);
  z-index: 40;
  display: none;
}
.drawer-mask.show { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 540px;
  max-width: 94vw;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -4px 0 20px rgba(21, 34, 48, 0.08);
  z-index: 41;
  display: none;
  flex-direction: column;
}
.drawer.show { display: flex; }

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.drawer-head .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }

.drawer-section { margin-bottom: 22px; }
.drawer-section > h3 {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 10px;
}

.qr-preview {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.qr-preview img {
  width: 132px;
  height: 132px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
}
.qr-meta { flex: 1; min-width: 0; }

.kv { display: flex; gap: 8px; font-size: 12.5px; margin-bottom: 7px; }
.kv .k { color: var(--ink-3); flex: 0 0 62px; }
.kv .v { color: var(--ink); word-break: break-all; }

.link-box {
  display: flex;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  padding: 6px 6px 6px 10px;
}
.link-box code {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 7px;
  background: var(--surface);
}
.target-item .t-url { flex: 1; min-width: 0; }
.target-item .t-url .u {
  font-size: 12.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
}
.target-item .t-hits { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

.risk-note {
  background: var(--warn-soft);
  border: 1px solid #ecdcb6;
  color: #7a5209;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.6;
  margin-bottom: 10px;
}

.add-target { display: flex; gap: 8px; }

/* ---------------- upload thumbnails ---------------- */

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.upload-cell {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
}
.upload-cell img {
  display: block;
  width: 100%;
  height: 84px;
  object-fit: contain;
  background: #fff;
}
.upload-ph {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-size: 11px;
}

/* 单张素材的删除按钮：悬停才明显，手机上也够大 */
.upload-del {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(21, 34, 48, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.upload-cell:hover .upload-del { opacity: 1; }
.upload-del:hover,
.upload-del:active {
  background: var(--danger, #c2410c);
  border-color: var(--danger, #c2410c);
  color: #fff;
  opacity: 1;
}
.upload-tag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--ink-2);
  padding: 2px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.orig-img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

/* ---------------- switch ---------------- */

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex: 0 0 auto;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--line-strong);
  border-radius: 10px;
  transition: background-color 0.15s ease;
  cursor: pointer;
}
.switch .track::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: left 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { left: 18px; }

/* ---------------- modal ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(27, 35, 45, 0.32);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask.show { display: flex; }

.modal {
  width: 100%;
  max-width: 400px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(21, 34, 48, 0.16);
  padding: 22px;
}
.modal h3 { margin: 0 0 8px; font-size: 15px; font-weight: 650; }
.modal p { margin: 0 0 20px; font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; }

/* ---------------- toast ---------------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  min-width: 200px;
  max-width: 380px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  color: var(--ink);
  border-left: 3px solid var(--brand);
  animation: toast-in 0.16s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- misc ---------------- */

.hidden { display: none !important; }
.muted { color: var(--ink-3); font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 9px; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

.progress {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 5px;
}
.progress > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width 0.2s ease; }

.section-note {
  font-size: 12.5px;
  color: var(--ink-3);
  margin: -4px 0 12px;
}

.lang-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 5px;
}

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar {
    position: static;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-brand { border-bottom: none; }
  .nav { display: flex; padding: 6px 10px 10px; overflow-x: auto; }
  .nav-item { width: auto; border-left: none; border-bottom: 2px solid transparent; }
  .nav-item.active { border-left: none; border-bottom-color: var(--brand); border-radius: 6px 6px 0 0; }
  .sidebar-foot { display: none; }
  .main { margin-left: 0; padding: 16px 14px 40px; }
  .search .input { width: 150px; }
  .drawer { width: 100%; max-width: 100%; }
}
