/* 网站访客监控平台 · 后台样式
 * 默认浅色（与 IDE 浅色主题一致），右上角可切深色。
 */

:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --panel-3: #f1f5f9;
  --border: #e3e9f2;
  --border-strong: #d3dce9;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: #edf3ff;
  --good: #059669;
  --good-soft: #e8f7f0;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --track: #eef2f7;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 28px -18px rgba(15, 23, 42, 0.24);
  --radius: 14px;
  --c1: #2563eb;
  --c2: #0ea5e9;
  --c3: #10b981;
  --c4: #f59e0b;
  --c5: #8b5cf6;
  --c6: #ef4444;
  --sidebar: #0e1729;
  --sidebar-text: #c7d3e6;
}

html[data-theme='dark'] {
  --bg: #080e19;
  --panel: #101a2b;
  --panel-2: #0d1625;
  --panel-3: #16223a;
  --border: #1e2c46;
  --border-strong: #2a3b59;
  --text: #e8eefb;
  --text-2: #c3cfe4;
  --muted: #8d9fbc;
  --faint: #6b7f9e;
  --brand: #5b8cff;
  --brand-strong: #3d74f5;
  --brand-soft: #16233d;
  --good: #34d399;
  --good-soft: #10281f;
  --warn: #fbbf24;
  --warn-soft: #2a2110;
  --bad: #f87171;
  --bad-soft: #2a1416;
  --track: #1a2740;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 32px -20px rgba(0, 0, 0, 0.7);
  --c1: #5b8cff;
  --c2: #38bdf8;
  --c3: #34d399;
  --c4: #fbbf24;
  --c5: #a78bfa;
  --c6: #f87171;
  --sidebar: #0a1220;
  --sidebar-text: #aebdd6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

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

body.no-scroll {
  overflow: hidden;
}

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

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

button {
  font-family: inherit;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

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

/* ---------------------------------- 登录页 ---------------------------------- */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--panel);
}

.login-hero {
  position: relative;
  overflow: hidden;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f2f7ff;
  background: radial-gradient(1200px 600px at 10% 0%, #1e3a8a 0%, #0b1530 55%, #070d1a 100%);
}

.login-hero::after {
  content: '';
  position: absolute;
  inset: -30% -10% auto auto;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.28), transparent 62%);
  pointer-events: none;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 650;
  font-size: 17px;
  position: relative;
  z-index: 1;
}

.login-hero h1 {
  position: relative;
  z-index: 1;
  font-size: 38px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  max-width: 460px;
}

.login-hero p.lead {
  position: relative;
  z-index: 1;
  color: #a9c0e4;
  max-width: 430px;
  margin: 18px 0 0;
  font-size: 15px;
}

.login-points {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  margin-top: 32px;
  max-width: 460px;
}

.login-point {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: #c8d8f2;
  font-size: 13.5px;
}

.login-point span.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  margin-top: 8px;
  flex: none;
}

.login-foot {
  position: relative;
  z-index: 1;
  color: #6f86a8;
  font-size: 12px;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card h2 {
  font-size: 24px;
  margin-bottom: 6px;
}

.login-card .sub {
  color: var(--muted);
  margin: 0 0 26px;
  font-size: 13.5px;
}

.login-error {
  display: none;
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
}

.login-error.show {
  display: block;
}

.login-hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--faint);
  line-height: 1.7;
}

/* ---------------------------------- 布局 ---------------------------------- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  color: #f1f6ff;
  font-weight: 650;
  font-size: 15.5px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex: none;
  box-shadow: 0 6px 16px -8px rgba(59, 130, 246, 0.9);
}

.brand small {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  color: #7d90ad;
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.nav-label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: #5f7495;
  padding: 14px 10px 6px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex: none;
  opacity: 0.75;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0.08));
  color: #fff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 #3b82f6;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: rgba(59, 130, 246, 0.25);
  color: #cfe0ff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: #6d80a0;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.main {
  margin-left: 220px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 26px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 17px;
  margin-right: auto;
  white-space: nowrap;
}

.topbar .crumb {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 8px;
}

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

.select,
.input {
  height: 34px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 9px;
  padding: 0 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.select {
  padding-right: 26px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.input:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}

.input::placeholder {
  color: var(--faint);
}

textarea.input {
  height: auto;
  padding: 9px 10px;
  resize: vertical;
  line-height: 1.6;
}

.btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.06s;
}

.btn:hover {
  background: var(--panel-3);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.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-strong);
}

.btn-danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(0.94);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: var(--panel-3);
}

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

.btn-lg {
  height: 44px;
  padding: 0 20px;
  font-size: 14.5px;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex: none;
}

.icon-btn:hover {
  background: var(--panel-3);
  color: var(--text);
}

.segment {
  display: inline-flex;
  padding: 3px;
  background: var(--panel-3);
  border-radius: 10px;
  border: 1px solid var(--border);
  gap: 2px;
}

.segment button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 500;
}

.segment button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 30px;
  font-size: 12.5px;
  color: var(--text-2);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #0ea5e9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.content {
  padding: 20px 26px 40px;
  max-width: 1560px;
  width: 100%;
}

/* ---------------------------------- 卡片 ---------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 0;
}

.card-head h3 {
  font-size: 13.5px;
  font-weight: 650;
}

.card-head .sub {
  font-size: 12px;
  color: var(--muted);
}

.card-head .spacer {
  margin-left: auto;
}

.card-body {
  padding: 14px 16px 16px;
}

.card-body.tight {
  padding: 10px 12px 12px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-main {
  grid-template-columns: minmax(0, 1.72fr) minmax(280px, 1fr);
  align-items: start;
}

.stack {
  display: grid;
  gap: 14px;
}

/* KPI */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 14px 15px 13px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 680;
  letter-spacing: -0.02em;
  margin-top: 6px;
  line-height: 1.15;
}

.kpi-value small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 3px;
}

.kpi-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--faint);
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 20px;
}

.delta.up {
  color: var(--good);
  background: var(--good-soft);
}

.delta.down {
  color: var(--bad);
  background: var(--bad-soft);
}

.delta.flat {
  color: var(--muted);
  background: var(--panel-3);
}

/* ---------------------------------- 表格 ---------------------------------- */

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

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--panel-2);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: color-mix(in srgb, var(--brand) 3.5%, transparent);
}

.table tr.clickable {
  cursor: pointer;
}

.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .cell-main {
  font-weight: 550;
  color: var(--text);
}

.table .cell-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.table .empty-cell {
  padding: 0;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 12px;
  color: var(--faint);
  font-size: 12.5px;
}

.empty-icon {
  font-size: 22px;
  opacity: 0.5;
}

.empty p {
  margin: 0;
}

.skeleton-row td {
  padding: 12px;
}

.skeleton-bar,
.skeleton-block {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--panel-3), var(--panel-2), var(--panel-3));
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  height: 14px;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* 徽标 */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 550;
  background: var(--panel-3);
  color: var(--text-2);
  white-space: nowrap;
  line-height: 1.7;
}

.badge-brand {
  background: var(--brand-soft);
  color: var(--brand);
}

.badge-good {
  background: var(--good-soft);
  color: var(--good);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.badge-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 11px;
  background: var(--panel-3);
  color: var(--muted);
}

.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  display: inline-block;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.08);
  }
}

/* ---------------------------------- 图表 ---------------------------------- */

.chart-box {
  position: relative;
  width: 100%;
}

.chart-box svg {
  display: block;
  overflow: visible;
}

.grid-line {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.axis-text {
  fill: var(--faint);
  font-size: 10.5px;
}

.hover-guide {
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-tip {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 5;
  min-width: 108px;
}

.chart-tip.show {
  opacity: 1;
}

.tip-title {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 3px;
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: var(--text-2);
}

.tip-row b {
  margin-left: auto;
  padding-left: 12px;
  color: var(--text);
}

.tip-row .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.donut-box {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 0;
}

.donut-total {
  fill: var(--text);
  font-size: 20px;
  font-weight: 650;
}

.donut-sub {
  fill: var(--muted);
  font-size: 10.5px;
}

/* 条形列表 */

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  font-size: 12.5px;
}

.bar-item .name {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-item .val {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar-track {
  grid-column: 1 / -1;
  height: 6px;
  background: var(--track);
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--c1), var(--c2));
}

/* 漏斗 */

.funnel {
  display: grid;
  gap: 10px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 168px 1fr 92px;
  align-items: center;
  gap: 14px;
}

.funnel-label {
  font-size: 12.5px;
  color: var(--text-2);
}

.funnel-bar-wrap {
  height: 30px;
  background: var(--panel-3);
  border-radius: 8px;
  overflow: hidden;
}

.funnel-bar {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  min-width: 34px;
  transition: width 0.4s ease;
}

.funnel-count {
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.funnel-count small {
  display: block;
  color: var(--faint);
  font-size: 11px;
}

/* 热区 */

.heatmap-stage {
  position: relative;
  width: 100%;
  height: 560px;
  background:
    linear-gradient(var(--panel-2) 1px, transparent 1px) 0 0 / 100% 56px,
    var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.heat-dot {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: multiply;
}

html[data-theme='dark'] .heat-dot {
  mix-blend-mode: screen;
}

.heat-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.heat-scale .grad {
  width: 96px;
  height: 8px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.15), rgba(245, 158, 11, 0.7), rgba(239, 68, 68, 0.9));
}

/* ---------------------------------- 抽屉 / 弹窗 ---------------------------------- */

.drawer-root,
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  visibility: hidden;
}

.drawer-root.open,
.modal-root.open {
  pointer-events: auto;
  visibility: visible;
}

.drawer-mask,
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(9, 15, 28, 0.42);
  opacity: 0;
  transition: opacity 0.2s;
}

.drawer-root.open .drawer-mask,
.modal-root.open .modal-mask {
  opacity: 1;
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 94vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 50px -30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(24px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.drawer.wide {
  width: min(760px, 96vw);
}

.drawer-root.open .drawer {
  transform: none;
  opacity: 1;
}

.drawer-head,
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-titles {
  min-width: 0;
}

.drawer-title,
.modal-title {
  font-size: 15.5px;
}

.drawer-sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.drawer-body,
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

.drawer-foot,
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}

.modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 12px));
  width: min(480px, 94vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal.wide {
  width: min(660px, 94vw);
}

.modal-root.open .modal {
  transform: translate(-50%, -50%);
  opacity: 1;
}

/* 详情 */

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.meta-item {
  min-width: 0;
}

.meta-item.full {
  grid-column: 1 / -1;
}

.meta-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 2px;
}

.meta-value {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 11px;
  min-width: 74px;
}

.chip b {
  display: block;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
}

.chip span {
  font-size: 11px;
  color: var(--muted);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 22px 0 10px;
  text-transform: uppercase;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* 时间线 */

.timeline {
  position: relative;
  margin: 0;
  padding: 0 0 0 22px;
  list-style: none;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}

.tl-item {
  position: relative;
  padding: 0 0 16px;
}

.tl-item::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--border-strong);
}

.tl-item.pv::before {
  border-color: var(--c1);
}

.tl-item.click::before {
  border-color: var(--c4);
}

.tl-item.form::before {
  border-color: var(--c5);
}

.tl-item.inquiry::before {
  border-color: var(--good);
  background: var(--good);
}

.tl-time {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.tl-title {
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
  word-break: break-word;
}

.tl-desc {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tl-click {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 4px;
  max-width: 100%;
}

.tl-click .x {
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* 表单 */

.form-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 550;
}

.field .hint {
  font-size: 11.5px;
  color: var(--faint);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* 分页 */

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.pager-info {
  font-size: 12px;
  color: var(--muted);
  margin-right: auto;
}

.pager-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.page-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-gap {
  color: var(--faint);
  padding: 0 2px;
}

/* Toast */

.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: grid;
  gap: 8px;
  justify-items: end;
}

.toast {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 360px;
}

.toast.in {
  opacity: 1;
  transform: none;
}

.toast-success {
  border-left: 3px solid var(--good);
}

.toast-error {
  border-left: 3px solid var(--bad);
}

.toast-info {
  border-left: 3px solid var(--brand);
}

/* 页面顶部工具行 */

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.page-head .titles {
  margin-right: auto;
}

.page-head h2 {
  font-size: 19px;
}

.page-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

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

.filters .input {
  height: 32px;
  font-size: 12.5px;
}

.filters .select {
  height: 32px;
  font-size: 12.5px;
}

.search-box {
  position: relative;
}

.search-box .input {
  padding-left: 30px;
  width: 220px;
}

.search-box .ico {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 12px;
  pointer-events: none;
}

.checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
  vertical-align: middle;
}

/* 站点卡片 */

.site-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--panel);
}

.site-card + .site-card {
  margin-top: 10px;
}

.site-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.site-card-head h4 {
  font-size: 14px;
}

.snippet {
  position: relative;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 40px 9px 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--text-2);
  overflow-x: auto;
  white-space: nowrap;
}

.snippet .copy {
  position: absolute;
  right: 4px;
  top: 4px;
}

.kv {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 6px 12px;
  font-size: 12.5px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  word-break: break-all;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

.notice {
  display: flex;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  background: var(--brand-soft);
  color: var(--text-2);
  border: 1px solid color-mix(in srgb, var(--brand) 18%, transparent);
}

.notice.warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}

.notice.good {
  background: var(--good-soft);
  border-color: color-mix(in srgb, var(--good) 25%, transparent);
}

.confirm-body p {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: var(--text-2);
}

/* 响应式 */

@media (max-width: 1180px) {
  .grid-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 20px 0 60px -30px rgba(0, 0, 0, 0.6);
  }
  .sidebar.open {
    transform: none;
  }
  .main {
    margin-left: 0;
  }
  .menu-toggle {
    display: inline-flex !important;
  }
  .content {
    padding: 14px 14px 40px;
  }
  .topbar {
    padding: 10px 14px;
  }
  .topbar h1 {
    font-size: 15px;
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .funnel-row {
    grid-template-columns: 120px 1fr 74px;
    gap: 8px;
  }
  .meta-grid {
    grid-template-columns: 1fr;
  }
  .login-screen {
    grid-template-columns: 1fr;
  }
  .login-hero {
    display: none;
  }
}

.menu-toggle {
  display: none;
}

@media (max-width: 640px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-value {
    font-size: 21px;
  }
  .search-box .input {
    width: 150px;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .drawer,
  .drawer.wide {
    width: 100vw;
  }
}

/* ------------------------------ 顶部进度条 ------------------------------ */

#progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  z-index: 300;
  opacity: 0;
  transition: width 0.26s ease, opacity 0.2s;
}

#progress.on {
  opacity: 1;
}

/* ------------------------------ 询盘正文 ------------------------------ */

.inquiry-message {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--panel-3);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--text-2);
}

.snippet .code {
  background: transparent;
  padding: 0;
  font-size: 11.5px;
}

details > summary {
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::before {
  content: '▸ ';
  color: var(--faint);
}

details[open] > summary::before {
  content: '▾ ';
}

.tl-item.download::before {
  border-color: var(--c3);
}

.tl-hint {
  margin: -4px 0 10px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--faint);
}

.tl-hint b {
  color: var(--text-2);
  font-weight: 600;
}

/* ------------------------------ 未提交草稿 ------------------------------ */

.draft-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.draft-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.draft-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}

.draft-row {
  display: flex;
  gap: 10px;
  padding: 3px 0;
  font-size: 13px;
  line-height: 1.7;
  border-top: 1px dashed var(--border);
}

.draft-row:first-of-type {
  border-top: 0;
}

.draft-key {
  flex: 0 0 74px;
  color: var(--faint);
  font-size: 12.5px;
}

.draft-val {
  flex: 1;
  min-width: 0;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}
