/* ==========================================================================
   Sitemap 监控 —— 简洁的 SaaS 风格
   原则：信息层级清晰、留白克制、状态明确；不加无用的图表与动画
   ========================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --border: #e6e8ec;
  --border-strong: #d3d7de;
  --text: #14171c;
  --text-2: #5b6472;
  --text-3: #8b93a1;
  --accent: #2f6feb;
  --accent-hover: #2559c4;
  --accent-soft: #eef3ff;
  --danger: #c0392f;
  --danger-soft: #fdf1f0;
  --warn: #9a6400;
  --warn-soft: #fff8e8;
  --ok: #17794a;
  --ok-soft: #eefaf3;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 16px -4px rgba(16, 24, 40, .10), 0 1px 3px rgba(16, 24, 40, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 56px;
  padding: 0 20px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  flex: none;
}
.brand-name { font-size: 14.5px; }

.nav { display: flex; gap: 2px; }
.nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
}
.nav a:hover { background: #eef0f3; color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.topbar-meta { color: var(--text-3); font-size: 12.5px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip .name { color: var(--text-2); font-size: 13px; }

/* ------------------------------------------------------------------ 布局 */
.page { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .sub { color: var(--text-3); font-size: 12.5px; }
.card-body { padding: 18px; }

/* ------------------------------------------------------------------ 指标 */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); }
.metric { background: var(--surface); padding: 16px 18px; }
.metric .label { color: var(--text-2); font-size: 12.5px; }
.metric .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; margin-top: 2px; }
.metric .sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.metric.alert { background: var(--danger-soft); }
.metric.alert .value, .metric.alert .label { color: var(--danger); }

/* ------------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn:hover:not(:disabled) { background: #f3f4f6; }
.btn:active:not(:disabled) { background: #eceef1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-hover); }

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

.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: #f0f1f4; }

/* ------------------------------------------------------------------ 表单 */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }

input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 235, .12);
}
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%238b93a1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.input-affix { position: relative; }
.input-affix input { padding-right: 40px; }
.affix {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--text-3); cursor: pointer;
}
.affix:hover { background: #f0f1f4; color: var(--text-2); }
.affix.on { color: var(--accent); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-2); }
.check input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }

.field-row { margin-bottom: 16px; }

details.advanced {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--surface-2);
}
details.advanced > summary { cursor: pointer; color: var(--text-2); font-size: 13px; list-style: none; }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before { content: "▸ "; color: var(--text-3); }
details.advanced[open] > summary::before { content: "▾ "; }
details.advanced > .adv-body { padding-top: 14px; }

/* ------------------------------------------------------------------ 提示条 */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 12px;
  font-size: 13.5px;
}
.notice::before { flex: none; font-weight: 700; }
.notice-info { background: var(--accent-soft); border-color: #d3e1fd; color: #1b4bb8; }
.notice-info::before { content: "i"; }
.notice-ok { background: var(--ok-soft); border-color: #c6ecd9; color: var(--ok); }
.notice-ok::before { content: "✓"; }
.notice-warn { background: var(--warn-soft); border-color: #f2e2bb; color: var(--warn); }
.notice-warn::before { content: "!"; }
.notice-error { background: var(--danger-soft); border-color: #f3d5d2; color: var(--danger); }
.notice-error::before { content: "×"; }

.form-error {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid #f3d5d2;
  color: var(--danger);
  font-size: 13.5px;
}

/* ------------------------------------------------------------------ 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  font-size: 12px; font-weight: 600; color: var(--text-2);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.cell-url { word-break: break-all; max-width: 460px; }
td.cell-actions { white-space: nowrap; }
td.cell-actions .btn + .btn { margin-left: 4px; }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty strong { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }

/* ------------------------------------------------------------------ 标签 */
.tag {
  display: inline-flex; align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px; color: var(--text-2); white-space: nowrap;
}
.tag-ok { background: var(--ok-soft); color: var(--ok); border-color: #c6ecd9; }
.tag-warn { background: var(--warn-soft); color: var(--warn); border-color: #f2e2bb; }
.tag-bad { background: var(--danger-soft); color: var(--danger); border-color: #f3d5d2; }
.tag-info { background: var(--accent-soft); color: var(--accent); border-color: #d3e1fd; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ 工具条 */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.toolbar select { width: auto; min-width: 132px; }
.toolbar .grow { flex: 1 1 240px; min-width: 200px; }
.toolbar-note { color: var(--text-3); font-size: 12.5px; }

.pager {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  color: var(--text-2); font-size: 13px;
}

.actions-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ 登录页 */
.auth-page { background: var(--bg); }
.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%;
  max-width: 384px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.auth-brand p { margin: 1px 0 0; color: var(--text-3); font-size: 12.5px; }
.auth-card .btn-primary { width: 100%; height: 38px; margin-top: 4px; }
.auth-foot { margin: 18px 0 0; text-align: center; color: var(--text-3); font-size: 12px; }
.auth-card .check span { font-size: 13px; }

/* ------------------------------------------------------------------ 弹窗 */
dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  width: min(620px, 92vw);
  box-shadow: 0 12px 40px -8px rgba(16, 24, 40, .22);
  color: var(--text);
}
dialog::backdrop { background: rgba(16, 24, 40, .38); }
.dlg-body { padding: 20px 22px; }
.dlg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.dlg-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; color: var(--text-2); margin-bottom: 16px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); }

/* ------------------------------------------------------------------ 响应式 */
@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .page { padding: 16px 12px 48px; }
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar .brand { display: none; }
  .topbar-meta { display: none; }
  .nav a { padding: 6px 8px; font-size: 13.5px; }
  .user-chip .name { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 13px 14px; }
  .metric .value { font-size: 22px; }
  .toolbar { padding: 12px 14px; }
  th, td { padding: 9px 10px; }
  td.cell-url { max-width: 220px; }
  .auth-card { padding: 24px 20px; }
}
