:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --sidebar: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
button, input, select { font: inherit; }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #2563eb 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
  padding: 40px 32px 28px;
  text-align: center;
}
.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 28px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-sub { margin: 0 0 24px; color: var(--muted); }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.login-tip { margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.err { color: #dc2626; min-height: 20px; font-size: 13px; text-align: left; padding-top: 6px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  transition: .15s;
}
.btn:hover { opacity: .85; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: #dc2626; color: #fff; }
.btn.ghost { border-color: var(--line); background: #fff; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; padding: 12px; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; padding: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
  color: #fff;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
}
#nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: block; width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-foot { padding: 12px 10px; border-top: 1px solid rgba(255, 255, 255, .08); }

.main { flex: 1; min-width: 0; }
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h2 { margin: 0; font-size: 17px; flex: 1; }
.menu-btn { display: none; border: 0; background: transparent; cursor: pointer; }
.menu-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--text); stroke-width: 2; }
.content { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* ---------- Cards & stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  border-left: 4px solid var(--primary);
}
.stat.green { border-color: #16a34a; }
.stat.purple { border-color: #7c3aed; }
.stat.orange { border-color: #f59e0b; }
.stat.cyan { border-color: #0891b2; }
.stat.teal { border-color: #0d9488; }
.stat.red { border-color: #dc2626; }
.stat-t { color: var(--muted); font-size: 13px; }
.stat-v { font-size: 30px; font-weight: 700; margin-top: 4px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-h { font-weight: 600; font-size: 15px; margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.loading, .empty { color: var(--muted); text-align: center; padding: 32px; }

/* ---------- Table ---------- */
.table-tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.table-tools input, .table-tools select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
}
.table-tools input:focus, .table-tools select:focus { border-color: var(--primary); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #f8fafc; }
tr:hover td { background: #f8fafc; }
td .cell-limit { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; background: #e2e8f0; color: #475569;
}
.badge.submitted, .badge.sent { background: #dbeafe; color: #1d4ed8; }
.badge.draft, .badge.skipped { background: #f1f5f9; color: #64748b; }
.badge.revoked, .badge.failed { background: #fee2e2; color: #b91c1c; }
.row-ops { display: flex; gap: 6px; }

.pager {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 12px; margin-top: 16px; color: var(--muted); font-size: 13px;
}

/* ---------- Analytics ---------- */
.dims { display: flex; gap: 6px; }
.dim {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 8px; padding: 6px 14px; cursor: pointer;
}
.dim.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-grid .full { grid-column: 1 / -1; }
.sub-h { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { font-size: 11px; fill: #94a3b8; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { width: 110px; flex: 0 0 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 10px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.bar-val { width: 42px; text-align: right; color: var(--muted); }

/* ---------- Modal & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); }
.modal-box {
  position: relative; width: 100%; max-width: 460px;
  background: #fff; border-radius: var(--radius); box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.modal-body input, .modal-body select {
  display: block; width: 100%; margin-top: 6px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; outline: none;
  color: var(--text);
}
.modal-body input:focus, .modal-body select:focus { border-color: var(--primary); }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.detail-item { border-bottom: 1px solid var(--line); padding: 8px 0; }
.detail-item:last-child { border: 0; }
/* ---------- 反馈管理 ---------- */
.nav-item .nav-badge {
  float: right; min-width: 20px; height: 20px; border-radius: 10px;
  background: #ef4444; color: #fff; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.fb-count { font-size: 12px; font-weight: 400; color: #dc2626; margin-left: 10px; }
.fb-group { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
.fb-group summary { padding: 12px 16px; cursor: pointer; font-weight: 600; background: #f8fafc; }
.fb-item { padding: 16px; border-top: 1px solid var(--line); }
.fb-item.fb-done { opacity: .6; }
.fb-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.fb-type, .fb-status { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #e2e8f0; color: #475569; }
.fb-user { font-weight: 600; }
.fb-content { font-size: 14px; color: var(--text); line-height: 1.7; white-space: pre-wrap; }
.fb-reply { margin-top: 10px; padding: 10px 12px; background: #eff6ff; border-radius: 8px; font-size: 13px; color: #1e40af; line-height: 1.6; }
.fb-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 12px; color: var(--muted); }
.fb-ops { display: flex; gap: 8px; }
.fb-detail-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.fb-detail-box { background: #f8fafc; padding: 12px; border-radius: 8px; line-height: 1.7; white-space: pre-wrap; }
.fb-detail-meta { font-size: 12px; color: var(--muted); margin-top: 8px; }
.fb-textarea {
  width: 100%; min-height: 120px; padding: 10px;
  border: 1px solid var(--line); border-radius: 8px; outline: none;
  font: inherit; resize: vertical;
}
.fb-textarea:focus { border-color: var(--primary); }

/* ---------- 版本信息 ---------- */
.version-card { max-width: 760px; margin: 0 auto; }
.version-hero { text-align: center; padding: 12px 0 24px; border-bottom: 1px solid var(--line); }
.version-logo {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff;
  font-size: 30px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.version-hero h2 { margin: 0 0 8px; }
.version-hero p { margin: 0; color: var(--muted); font-size: 14px; }
.version-current { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 20px 0; }
.version-tag { background: #dbeafe; color: #1d4ed8; padding: 4px 12px; border-radius: 999px; font-size: 12px; }
.version-num { font-size: 28px; font-weight: 700; }
.version-date { color: var(--muted); font-size: 13px; }
.version-section-title { font-size: 15px; margin: 8px 0 16px; }
.version-item { border-left: 3px solid var(--primary); padding: 0 0 4px 16px; margin-bottom: 22px; }
.version-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.version-badge { background: var(--primary); color: #fff; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.version-item .version-date { margin-left: auto; }
.version-item ul { margin: 10px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.9; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 20px; border-radius: 999px;
  z-index: 100; box-shadow: var(--shadow); font-size: 13px;
}

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-grid .full { grid-column: auto; }
}
