/* ============================================================
   通用样式 (管理端与填写端共用基础)
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warn: #f59e0b;
  --success: #10b981;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  line-height: 1.2;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: var(--danger);
}
.btn-warn {
  background: #fff;
  border-color: #fde68a;
  color: #b45309;
}
.btn-warn:hover {
  background: #fffbeb;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover {
  background: var(--gray-100);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
}
.btn-block {
  width: 100%;
}

/* ---------- 表单 ---------- */
.field {
  display: block;
  margin-bottom: 14px;
}
.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--gray-600);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field input[type="datetime-local"],
.field input[type="url"],
.field input:not([type]),
.field textarea,
.field select {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: #fff;
  color: var(--gray-800);
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.field textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}
.field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
}
.field-check input {
  width: 16px;
  height: 16px;
}
.color-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.color-field > span {
  margin-bottom: 0;
}
.color-field input[type="color"] {
  width: 48px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.inline-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 999px;
  font-weight: 500;
}
.badge-gray {
  background: var(--gray-100);
  color: var(--gray-600);
}
.badge-green {
  background: #d1fae5;
  color: #047857;
}
.badge-red {
  background: #fee2e2;
  color: #b91c1c;
}

/* ---------- 提示 ---------- */
.toast-wrap {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--gray-800);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.25s ease;
  max-width: 80vw;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success {
  background: var(--success);
}
.toast-error {
  background: var(--danger);
}

/* ---------- 模态框 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow: auto;
  box-shadow: var(--shadow);
}
.modal-wide {
  max-width: 760px;
}
.modal-sm {
  max-width: 380px;
}
.modal-head {
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--gray-200);
}
.modal-body {
  padding: 20px;
  color: var(--gray-700);
}
.modal-foot {
  padding: 14px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--gray-200);
}

/* ---------- 面板 ---------- */
.panel {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.panel h3 {
  font-size: 15px;
  margin-bottom: 16px;
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}
.table th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  white-space: nowrap;
}
.table tr:hover td {
  background: var(--gray-50);
}

/* ---------- 其他 ---------- */
.loading,
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--gray-500);
}
.muted {
  color: var(--gray-500);
  font-size: 13px;
}
.spacer {
  flex: 1;
}

/* ---------- 图表 ---------- */
.chart-donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 160px;
}
.chart-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}
.legend-label {
  flex: 1;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend-value {
  color: var(--gray-500);
  font-variant-numeric: tabular-nums;
}
.chart-center-num {
  font-size: 22px;
  font-weight: 700;
  fill: var(--gray-800);
}
.chart-center-label {
  font-size: 11px;
  fill: var(--gray-500);
}
.chart-empty {
  padding: 20px;
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
}
.chart-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chart-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chart-bar-label {
  width: 140px;
  flex: none;
  font-size: 13px;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chart-bar-track {
  flex: 1;
  height: 18px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}
.chart-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.chart-bar-value {
  width: 40px;
  flex: none;
  text-align: right;
  font-size: 13px;
  color: var(--gray-600);
  font-variant-numeric: tabular-nums;
}
.chart-line-wrap {
  width: 100%;
}
.chart-line-grid {
  stroke: var(--gray-200);
  stroke-width: 1;
}
.chart-line-tick {
  font-size: 11px;
  fill: var(--gray-500);
}
.chart-line-path {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-line-area {
  opacity: 0.1;
}
