/* ============================================================
   Beacon Monitor — admin styles (extends app.css)
   ============================================================ */

body { min-height: 100vh; }

.btn-primary {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(79, 70, 229, 0.8);
}
.btn-primary:hover { background: #5b53f0; color: #fff; border-color: transparent; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

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

.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-sm .i { width: 13px; height: 13px; }

/* 有些按钮是 <a>（比如跳申请页），去掉链接自带的下划线 */
a.btn,
a.btn:hover { text-decoration: none; }

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

.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  padding: 32px 28px 24px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 4px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand);
}
.login-icon svg { width: 23px; height: 23px; }

.login-card h1 { margin: 0; font-size: 19px; font-weight: 680; letter-spacing: -0.02em; }
.login-card > p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }

.login-card input {
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--card-soft);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.login-card .btn-primary { height: 42px; justify-content: center; font-size: 14px; margin-top: 4px; }
.login-error { min-height: 16px; font-size: 12.5px; color: var(--red); }
.login-back { margin-top: 6px; font-size: 12.5px; color: var(--muted-2); }
.login-back:hover { color: var(--brand); }

/* ---------------- layout ---------------- */

.admin-page { padding-bottom: 40px; }

.admin-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 14px;
  padding: 0 2px;
}
.admin-toolbar h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.admin-toolbar p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

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

.table-card,
.settings-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 760px;
}
.admin-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 12px 14px;
  background: var(--card-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: var(--card-soft); }
.admin-table .row-disabled { opacity: 0.55; }
.col-actions { text-align: right; }
.admin-table td.col-actions { text-align: right; white-space: nowrap; }

.cell-name { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.cell-url {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted-2);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-url:hover { color: var(--brand); }

.badge-off {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--muted-2);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: middle;
}
.badge-auto {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: middle;
}

.table-empty { text-align: center; padding: 40px 0 !important; color: var(--muted-2); }

.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }

/* ---------------- settings ---------------- */

.settings-card { margin-top: 22px; padding: 20px 22px 22px; }
.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.settings-head h2 { margin: 0; font-size: 15.5px; font-weight: 660; letter-spacing: -0.01em; }
.settings-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 550; }
.field input[type="text"],
.field input[type="url"],
.field input[type="password"],
.field input[type="number"] {
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--card-soft);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input::placeholder { color: var(--muted-2); }

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card-soft);
  align-self: end;
}
.field-inline > span { order: 1; font-size: 13.5px; color: var(--text-2); }
.field-inline input[type="checkbox"] {
  order: 2;
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* ---------------- editor ---------------- */

.editor-panel { width: min(620px, 100%); }
.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.editor-actions .btn { min-width: 78px; justify-content: center; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(17, 20, 27, 0.94);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.6);
  animation: toastIn 0.2s ease;
}
.toast.is-error { background: #b91c1c; }
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .admin-toolbar { align-items: flex-start; flex-direction: column; }
  .settings-card { padding: 16px; }
}

/* ---------------- 博客接入 ---------------- */

.snippets {
  display: grid;
  gap: 12px;
}

.snippet {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  overflow: hidden;
}

.snippet header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.snippet-title { display: flex; align-items: center; gap: 7px; }
.snippet-title b { font-size: 13px; font-weight: 660; }
.snippet header p {
  flex: 1 1 auto;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}
.snippet header .btn { flex: 0 0 auto; }

.tag-rec {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--brand-soft, rgba(79, 70, 229, 0.12));
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 660;
}

.snippet pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--code-bg, rgba(15, 18, 25, 0.04));
}
.snippet code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre;
}

@media (max-width: 720px) {
  .snippet header { flex-wrap: wrap; }
  .snippet header p { order: 3; flex-basis: 100%; }
}

/* ---------------- 版本与更新 ---------------- */

.version-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.version-pill:hover { border-color: var(--brand); color: var(--brand); }
.version-pill[data-state="update"] { border-color: #f59e0b; color: #b45309; background: rgba(245, 158, 11, 0.08); }
.version-pill[data-state="error"] { color: var(--muted-2); }
.version-pill.is-busy { opacity: 0.65; pointer-events: none; }

.version-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green, #22c55e);
  flex: 0 0 auto;
}
.version-pill[data-state="update"] .version-dot { background: #f59e0b; }
.version-pill[data-state="error"] .version-dot { background: var(--muted-2); }

.update-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.09), rgba(245, 158, 11, 0.04));
}
.update-banner[hidden] { display: none; }

.update-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  flex: 0 0 auto;
}
.update-icon .i, .update-icon svg { width: 18px; height: 18px; }

.update-body { flex: 1 1 auto; min-width: 0; }
.update-body h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 660;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.update-body h3 code {
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.18);
  color: #92400e;
  font-size: 12.5px;
  font-weight: 700;
}
.update-current { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.update-body p { margin: 5px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }

.update-cmd {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 7px 9px 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.update-cmd code {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: nowrap;
  color: var(--text);
}
.update-actions { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }

@media (max-width: 720px) {
  .update-banner { flex-wrap: wrap; }
  .update-actions { flex-direction: row; width: 100%; }
  .version-pill { padding: 0 9px; }
}

/* ---------------- 互动统计 ---------------- */

.engage-card { margin-top: 18px; }

.tag-ver {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: 2px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 1px;
  margin: 0 18px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
}

.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 14px 13px;
  background: var(--card);
}
.stat-cell span { font-size: 11.5px; color: var(--muted); }
.stat-cell strong {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-trend { padding: 18px 18px 0; }

.stat-trend-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}
.stat-trend-peak { font-variant-numeric: tabular-nums; }

.stat-bars {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 88px;
}

.stat-bar {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}
.stat-bar i {
  display: block;
  width: 100%;
  max-width: 24px;
  min-height: 2px;
  border-radius: 4px 4px 2px 2px;
  background: var(--brand-soft);
  transition: height 0.3s ease;
}
.stat-bar.is-zero i { background: rgba(128, 128, 128, 0.16); min-height: 3px; }
.stat-bar.is-today i { background: var(--brand); }
.stat-bar em {
  font-style: normal;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 18px 10px;
}
.stat-list-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; }

.stat-select {
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--card-soft);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.stat-table { min-width: 660px; }
.stat-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-title b {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-title code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted-2);
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.engage-snippets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  padding: 20px 18px 4px;
}

.engage-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px 18px;
}
.engage-tip {
  margin: 0;
  max-width: 76%;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted-2);
}

.friends-card { margin-top: 18px; }
.friend-stats { margin-bottom: 18px; }

.friend-table { min-width: 720px; }
.moment-table { min-width: 620px; }

.friend-note {
  font-size: 11.5px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.moment-title {
  display: inline-block;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
}
.moment-title:hover { color: var(--brand); text-decoration: underline; }

/* 接入代码里有很长的 script 标签，允许换行，避免横向截断 */
.engage-snippets .snippet pre code {
  white-space: pre-wrap;
  word-break: break-all;
}
.engage-snippets .snippet-title b { white-space: nowrap; }

@media (max-width: 720px) {
  .engage-foot { flex-direction: column; align-items: flex-start; }
  .engage-tip { max-width: 100%; }
  .stat-bars { gap: 3px; }
  .stat-bar em { font-size: 9.5px; }
}
