/* ==========================================================================
   管理后台样式 —— 与地图应用同源的浅色设计语言
   ========================================================================== */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --text: #1c2024;
  --text-2: #5b6470;
  --text-3: #8a929c;
  --brand: #1f6feb;
  --brand-dark: #1858bd;
  --brand-soft: #e8f1fe;
  --success: #12805c;
  --success-soft: #e6f5ef;
  --warn: #b8730a;
  --warn-soft: #fdf3e3;
  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --purple: #6b4fbb;
  --purple-soft: #f0ecfb;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, 0.14);
  --radius: 8px;
  --radius-lg: 12px;
  --topbar-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }
.hidden { display: none !important; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef3fb 0%, #f5f6f8 50%, #eaf6f1 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}

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

.brand-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
  flex: 0 0 auto;
}

.login-brand strong { display: block; font-size: 16px; }
.login-brand small { color: var(--text-3); font-size: 12px; }

.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card .sub { color: var(--text-2); font-size: 13px; margin: 0 0 22px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field .hint { font-size: 11px; color: var(--text-3); margin-top: 5px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.94); }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); border-color: #cfe0fb; }
.btn-soft:hover:not(:disabled) { background: #dbe9fd; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.alert {
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #f5c9c4; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #f0dcb4; }
.alert-info { background: var(--brand-soft); color: var(--brand-dark); border-color: #cfe0fb; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #bfe3d5; }

/* ---------- 后台布局 ---------- */
.admin-shell { display: flex; flex-direction: column; min-height: 100vh; }

.admin-topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}
.admin-topbar .brand { display: flex; align-items: center; gap: 10px; }
.admin-topbar .brand-text strong { display: block; font-size: 15px; }
.admin-topbar .brand-text small { color: var(--text-3); font-size: 11px; }
.admin-topbar .spacer { flex: 1; }
.admin-topbar .who { font-size: 13px; color: var(--text-2); }
.admin-topbar .who b { color: var(--text); }

.admin-body {
  flex: 1;
  display: grid;
  grid-template-columns: 216px 1fr;
  gap: 20px;
  padding: 20px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: sticky;
  top: calc(var(--topbar-h) + 20px);
  align-self: start;
}
.admin-nav button {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.admin-nav button:hover { background: var(--surface); color: var(--text); }
.admin-nav button.active {
  background: var(--surface);
  color: var(--brand-dark);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.admin-nav .nav-ico { width: 16px; text-align: center; opacity: .8; }

.admin-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 { font-size: 15px; margin: 0; }
.card-head .sub { font-size: 12px; color: var(--text-3); }
.card-head .spacer { flex: 1; }

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat .k { font-size: 11px; color: var(--text-3); margin-bottom: 6px; letter-spacing: .02em; }
.stat .v { font-size: 23px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 2px; }
.stat .sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.stat.is-ok .v { color: var(--success); }
.stat.is-warn .v { color: var(--warn); }
.stat.is-danger .v { color: var(--danger); }
.stat.is-brand .v { color: var(--brand); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px -18px; padding: 0 20px 4px; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data .mono { font-family: var(--mono); font-size: 12px; }
table.data .num { font-variant-numeric: tabular-nums; text-align: right; }
.empty { text-align: center; color: var(--text-3); padding: 28px 12px; font-size: 13px; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-gray { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.badge-blue { background: var(--brand-soft); color: var(--brand-dark); border-color: #cfe0fb; }
.badge-green { background: var(--success-soft); color: var(--success); border-color: #bfe3d5; }
.badge-amber { background: var(--warn-soft); color: var(--warn); border-color: #f0dcb4; }
.badge-red { background: var(--danger-soft); color: var(--danger); border-color: #f5c9c4; }
.badge-purple { background: var(--purple-soft); color: var(--purple); border-color: #ddd4f5; }

/* ---------- 任务卡片 ---------- */
.job-list { display: flex; flex-direction: column; gap: 10px; }
.job {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  background: var(--surface-2);
}
.job.running { border-color: #cfe0fb; background: #fbfdff; }
.job.failed { border-color: #f5c9c4; background: #fffbfb; }
.job-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.job-title { font-weight: 600; font-size: 13px; }
.job-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.job-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

.progress {
  height: 7px;
  border-radius: 999px;
  background: #e9edf2;
  overflow: hidden;
  margin: 10px 0 7px;
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, #4f92f7 100%);
  border-radius: 999px;
  transition: width .35s ease;
}
.progress.is-fail > i { background: linear-gradient(90deg, #c0392b 0%, #e0674f 100%); }
.job-msg { font-size: 12px; color: var(--text-2); }

.job-log {
  margin-top: 9px;
  background: #1e2330;
  color: #c7d2e4;
  border-radius: 6px;
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.65;
  max-height: 190px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.job-log:empty { display: none; }

/* ---------- 表单网格 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px 14px;
}
.form-grid .span-2 { grid-column: span 2; }
.check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-2);
  padding-top: 20px;
}
.check-row input { width: auto; }

/* 城市多选 */
.city-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 7px;
  max-height: 210px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.city-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.city-chip:hover { border-color: var(--border-strong); }
.city-chip input { width: auto; margin: 0; }
.city-chip .st { font-size: 10px; margin-left: auto; color: var(--text-3); }
.city-chip.has-data { border-color: #bfe3d5; background: #f6fcf9; }
.city-chip.has-data .st { color: var(--success); }

/* ---------- 密钥展示 ---------- */
.key-reveal {
  margin-top: 12px;
  border: 1px solid #bfe3d5;
  background: var(--success-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.key-reveal .lbl { font-size: 12px; color: var(--success); font-weight: 600; margin-bottom: 7px; }
.key-plain {
  display: flex;
  align-items: center;
  gap: 8px;
}
.key-plain code {
  flex: 1;
  background: #fff;
  border-color: #bfe3d5;
  font-size: 12px;
  padding: 7px 9px;
  overflow-x: auto;
  white-space: nowrap;
}

/* ---------- 杂项 ---------- */
.row-actions { display: flex; gap: 6px; }
.muted { color: var(--text-3); font-size: 12px; }
.mt { margin-top: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-inline input {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  min-width: 180px;
}
.toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.toast {
  background: #1e2330;
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
  max-width: 360px;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.spin {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .admin-body { grid-template-columns: 1fr; padding: 14px; }
  .admin-nav { flex-direction: row; overflow-x: auto; position: static; }
  .admin-nav button { white-space: nowrap; }
}

/* 七牛云页：复选行（同步范围 / 上传选项） */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
}
.checkbox-row input[type='checkbox'] { width: 15px; height: 15px; accent-color: var(--brand, #2563eb); }
