/* crm4kol 控制台样式 —— 项目自有设计，未使用任何外部设计系统。 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #171a1f;
  --text-muted: #6b7280;
  --accent: #0f766e;
  --accent-soft: #d7f0ec;
  --warn: #b45309;
  --warn-soft: #fdf0d9;
  --danger: #b91c1c;
  --danger-soft: #fbe3e3;
  --ok: #15803d;
  --ok-soft: #ddf3e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #24282f;
    --border: #2f343d;
    --text: #e8eaed;
    --text-muted: #9aa2ae;
    --accent: #2dd4bf;
    --accent-soft: #10312e;
    --warn: #fbbf24;
    --warn-soft: #3a2c10;
    --danger: #f87171;
    --danger-soft: #3a1a1a;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- 布局 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand span { color: var(--accent); }

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head h1 { font-size: 20px; margin: 0 0 2px; }
.page-head p { margin: 0; color: var(--text-muted); }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card-sub { color: var(--text-muted); font-size: 12px; margin: -8px 0 12px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--text-muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat .hint { font-size: 12px; color: var(--text-muted); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 28px; text-align: center; color: var(--text-muted); }

/* ---------------- 控件 ---------------- */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

input, select, textarea, button {
  font: inherit;
  color: inherit;
}
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
}
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

button {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-weight: 500;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.ghost:hover { background: var(--surface-2); filter: none; }
button.danger { background: var(--danger); }
button.small { padding: 4px 9px; font-size: 12px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.msg-body {
  white-space: pre-wrap;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 280px;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  min-width: 2px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: 360px;
}
.toast.error { border-left-color: var(--danger); }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-muted); margin: 0 0 20px; font-size: 13px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.field input { width: 100%; }
.login-card button { width: 100%; margin-top: 8px; }
.hint-box {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
}
.error-text { color: var(--danger); font-size: 13px; min-height: 20px; }

details.raw { margin-top: 10px; }
details.raw summary { cursor: pointer; color: var(--text-muted); font-size: 12px; }
pre { overflow-x: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; }
