:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1f2430;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}
.container.wide { max-width: 1160px; }

/* 顶部导航 */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 15px;
}
.nav-links { display: flex; gap: 8px; }
.nav-links a {
  padding: 8px 14px; border-radius: 8px; color: var(--text-muted); font-size: 14px;
}
.nav-links a:hover { background: var(--primary-soft); color: var(--primary); }
.nav-links a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 6px; font-size: 18px; }
.card .sub { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }

/* 表单 */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: .9; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* 提示条 */
.alert {
  padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px;
  display: none;
}
.alert.show { display: block; }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; }

/* 拖拽上传 */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .icon { font-size: 36px; margin-bottom: 8px; }
.dropzone p { margin: 4px 0; color: var(--text-muted); font-size: 14px; }
.dropzone .file-name { font-weight: 600; color: var(--text); }

/* 进度条 */
.progress-wrap { margin: 16px 0; display: none; }
.progress-wrap.show { display: block; }
.progress-track {
  height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  border-radius: 999px;
  transition: width .2s ease;
}
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* 徽章 */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-disabled { background: var(--danger-soft); color: var(--danger); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-failed { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #f3f4f6; color: var(--text-muted); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 13px; background: #fafbfc; }
tbody tr:hover { background: #fafbfc; }
.mono { font-family: "SF Mono", ui-monospace, Consolas, monospace; font-size: 13px; }
.key-cell { display: flex; align-items: center; gap: 6px; }
.copy-btn { cursor: pointer; border: none; background: none; color: var(--text-muted); font-size: 13px; }
.copy-btn:hover { color: var(--primary); }

/* 统计卡 */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat-card .label { color: var(--text-muted); font-size: 13px; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }

/* 工具条 */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; }
.spacer { flex: 1; }

/* 弹窗 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45);
  display: none; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px; max-height: 85vh; overflow: auto;
}
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; }

/* 图表（纯 CSS 条形图） */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart .bar {
  width: 100%; max-width: 42px; background: linear-gradient(180deg, #818cf8, #6366f1);
  border-radius: 4px 4px 0 0; min-height: 2px;
}
.chart .bar-label { font-size: 11px; color: var(--text-muted); }
.chart .bar-value { font-size: 11px; color: var(--text); font-weight: 600; }

/* 页脚 */
.footer { text-align: center; color: var(--text-muted); font-size: 13px; padding: 30px 0 40px; }

/* 结果区 */
.result-box { margin-top: 20px; display: none; }
.result-box.show { display: block; }
.result-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* 分享链接 */
.gen-item { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.gen-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.link-preview { color: var(--text-muted); font-size: 12px; word-break: break-all; margin-top: 6px; }

/* 移动端 */
@media (max-width: 640px) {
  .card { padding: 18px; }
  .input-group { flex-direction: column; }
  .topbar .nav-links a span { display: none; }
}
