:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e7eaef;
  --line-strong: #d8dde5;
  --text: #101828;
  --text-2: #475467;
  --text-3: #8a94a6;
  --brand: #2563eb;
  --brand-soft: #eef4ff;
  --pv: #2563eb;
  --uv: #12b3a8;
  --good: #0f9d58;
  --bad: #e5484d;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
table { border-collapse: collapse; width: 100%; }

/* ------------------------------ 基础布局 ------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  height: 58px; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #2563eb, #12b3a8);
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
}
.nav { display: flex; gap: 4px; margin-left: 6px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 7px 13px; border-radius: 9px; color: var(--text-2);
  font-size: 13.5px; white-space: nowrap; transition: .15s;
}
.nav a:hover { background: #f1f4f9; color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(15,157,88,.14); }

.page { max-width: 1180px; margin: 0 auto; padding: 26px 20px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-h { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-h h3 { font-size: 14.5px; }
.card-h .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }
.card-b { padding: 16px 18px; }

.section { margin-top: 20px; }
.grid { display: grid; gap: 14px; }
.g-2 { grid-template-columns: 1fr 1fr; }
.g-kpi { grid-template-columns: repeat(4, 1fr); }

/* ------------------------------ KPI ------------------------------ */
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin-top: 6px; line-height: 1.15; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.kpi .foot { margin-top: 8px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 8px; }

.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--text-3); }

/* ------------------------------ 站点卡片 ------------------------------ */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.site-card { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 12px; transition: .16s; cursor: pointer; position: relative; overflow: hidden; }
.site-card:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(16,24,40,.05), 0 16px 32px -18px rgba(16,24,40,.28); border-color: var(--line-strong); }
.site-card .sc-top { display: flex; align-items: flex-start; gap: 10px; }
.site-card .sc-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.site-card .sc-dom { font-size: 12px; color: var(--text-3); }
.site-card .sc-badge { margin-left: auto; }
.site-card .sc-metrics { display: flex; gap: 18px; }
.site-card .sc-m { }
.site-card .sc-m .n { font-size: 19px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.site-card .sc-m .t { font-size: 11.5px; color: var(--text-3); }
.site-card .sc-spark { margin: 0 -4px; }
.site-card .sc-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--text-3); border-top: 1px dashed var(--line); padding-top: 10px; }
.site-card .sc-alert { color: var(--bad); font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.live { background: rgba(15,157,88,.1); color: #0b7a44; }
.badge.idle { background: #f2f4f7; color: var(--text-3); }
.badge.new { background: rgba(229,72,77,.1); color: #c92a2f; }
.badge.off { background: #f2f4f7; color: var(--text-3); }

/* ------------------------------ 图表 ------------------------------ */
.chart-wrap { width: 100%; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }

.barlist { display: flex; flex-direction: column; gap: 11px; }
.barlist .row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.barlist .k { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist .v { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.barlist .bar { grid-column: 1 / -1; height: 6px; border-radius: 4px; background: #f1f3f7; overflow: hidden; }
.barlist .bar span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #2563eb, #5b8bff); }
.barlist.teal .bar span { background: linear-gradient(90deg, #12b3a8, #4fd1c5); }

.empty { padding: 26px 10px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ------------------------------ 表格 ------------------------------ */
.table { font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .path { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ------------------------------ 询盘 ------------------------------ */
.inq { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.inq:last-child { border-bottom: none; }
.inq-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.inq-name { font-weight: 650; font-size: 14px; }
.inq-company { color: var(--text-2); font-size: 12.5px; }
.inq-time { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.inq-contact { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 5px; font-size: 12.5px; color: var(--brand); }
.inq-contact span { color: var(--text-2); }
.inq-msg { margin-top: 7px; color: var(--text-2); font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.inq-meta { margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }
.inq-actions { margin-top: 9px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------ 按钮 / 表单 ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: .14s; white-space: nowrap;
}
.btn:hover { background: #f8fafc; border-color: #c6ccd6; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { background: #1d55d0; border-color: #1d55d0; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: #f1f4f9; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.danger { color: var(--bad); border-color: #f3c9ca; }
.btn.danger:hover { background: #fdf3f3; }
.btn.block { width: 100%; }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 11px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  font-size: 13.5px; font-family: inherit; outline: none; transition: .14s;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.field .tip { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }

.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.pills { display: inline-flex; background: #eef1f6; border-radius: 10px; padding: 3px; gap: 2px; }
.pills button {
  border: 0; background: transparent; padding: 6px 11px; border-radius: 8px;
  font-size: 12.5px; color: var(--text-2); cursor: pointer; transition: .14s; white-space: nowrap;
}
.pills button.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.1); }

/* ------------------------------ 登录 ------------------------------ */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1000px 500px at 15% -10%, #e8f0ff 0%, transparent 60%),
  radial-gradient(800px 400px at 100% 100%, #e6fbf8 0%, transparent 55%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; padding: 30px 28px; }
.auth-card h1 { font-size: 19px; letter-spacing: -.02em; }
.auth-card p.sub { color: var(--text-3); font-size: 13px; margin-top: 5px; margin-bottom: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }

/* ------------------------------ 杂项 ------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: #101828; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .22s; z-index: 100;
  max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(16,24,40,.42); backdrop-filter: blur(2px); }
.modal-body { position: relative; width: 100%; max-width: 560px; background: #fff; border-radius: 16px; padding: 22px; box-shadow: 0 24px 64px -12px rgba(16,24,40,.3); max-height: 86vh; overflow: auto; }
.modal-body h3 { font-size: 16px; margin-bottom: 6px; }
.modal-body .muted { color: var(--text-3); font-size: 12.5px; margin-bottom: 14px; }
.code {
  background: #0f172a; color: #dbeafe; border-radius: 10px; padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-all; margin: 0;
}

.loading { display: grid; place-items: center; padding: 60px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid #e3e8f0; border-top-color: var(--brand); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.app-loading { display: grid; place-items: center; min-height: 100vh; }

.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12.5px; margin-bottom: 8px; cursor: pointer; }
.crumb:hover { color: var(--brand); }

.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 11px;
  background: #fff8e6; border: 1px solid #f7e2b0; color: #8a5d00; font-size: 12.5px;
}
.notice .btn { margin-left: auto; }

.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 900px) {
  .g-kpi { grid-template-columns: 1fr 1fr; }
  .g-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar-inner { height: auto; padding: 10px 14px 8px; flex-wrap: wrap; gap: 8px; }
  .nav { order: 3; width: 100%; margin: 0; padding-bottom: 2px; }
  .nav a { padding: 6px 11px; font-size: 13px; }
  .page { padding: 16px 14px 90px; }
  .page-head h1 { font-size: 18px; }
  .kpi .value { font-size: 23px; }
  .kpi { padding: 14px; }
  .card-h, .card-b { padding: 13px 14px; }
  .site-grid { grid-template-columns: 1fr; }
  .table .path { max-width: 150px; }
  .hide-sm { display: none !important; }
  .inq-time { margin-left: 0; }
  .modal-body { padding: 18px; }
}
