/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .2s var(--ease-out), box-shadow .25s var(--ease-out);
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg, .btn i { width: 14px; height: 14px; stroke-width: 2; }

.btn-primary {
  color: #fff;
  background: var(--grad-metal);
  background-size: 200% 200%;
  box-shadow:
    0 1px 0 rgba(255,255,255,.25) inset,
    0 -1px 0 rgba(0,0,0,.12) inset,
    var(--shadow-brand);
  animation: metal-shift 6s ease-in-out infinite;
}
.btn-primary::before {
  content:''; position:absolute; left:0; right:0; top:0; height:50%;
  background: linear-gradient(180deg, rgba(255,255,255,.22), transparent);
  pointer-events: none;
}
.btn-primary::after {
  content:''; position:absolute; top:0; left:0; width:100%; height:100%;
  background: var(--grad-sheen);
  transform: translateX(-120%) skewX(-20deg);
  animation: sheen 3.5s ease-in-out infinite;
  pointer-events: none;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, 0 -1px 0 rgba(0,0,0,.15) inset,
              0 14px 32px -10px rgba(79,70,229,.55);
  transform: translateY(-1px);
}
@keyframes metal-shift { 0%,100%{background-position:0% 50%} 50%{background-position:100% 50%} }
@keyframes sheen {
  0% { transform: translateX(-120%) skewX(-20deg); }
  55%,100% { transform: translateX(220%) skewX(-20deg); }
}

.btn-secondary {
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-inset), var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--brand-300); color: var(--brand-600);
  box-shadow: var(--shadow-inset), 0 0 0 3px var(--brand-50);
}

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px dashed var(--border-default);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--brand-600); border-color: var(--brand-300); background: var(--brand-50);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg,#ef4444,#dc2626);
  box-shadow: 0 10px 30px -10px rgba(239,68,68,.5);
}
.btn-danger:hover:not(:disabled){ transform: translateY(-1px); }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--r-sm); }
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: var(--r-xs); }

.btn-text {
  background: transparent; color: var(--brand-600); padding: 4px 8px;
  font-size: 13px; border: none; cursor: pointer;
}
.btn-text:hover { color: var(--brand-700); background: var(--brand-50); border-radius: 4px; }

/* 图标按钮 */
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  border: 1px solid var(--border-default); background: var(--bg-surface);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
  transition: all .2s var(--ease-out); position: relative;
}
.icon-btn:hover { color: var(--brand-600); border-color: var(--brand-200); background: var(--brand-50); }
.icon-btn svg, .icon-btn i { width: 14px; height: 14px; }

/* ============================================================
   卡片 / 表面
   ============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 16px; font-weight: 700; font-family: var(--font-display); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-soft);
}

/* KPI 卡 */
.kpi {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: 22px;
  overflow: hidden;
  transition: all .3s var(--ease-out);
}
.kpi:hover {
  border-color: var(--brand-200);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}
.kpi::after {
  content: ''; position: absolute; top: -30%; right: -20%;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand-100), transparent 70%);
  opacity: 0.3; transition: opacity .4s var(--ease-out); pointer-events: none;
}
.kpi:hover::after { opacity: 0.8; }
/* 顶部细高光条 */
.kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand-400), transparent);
  opacity: 0; transition: opacity .3s;
}
.kpi:hover::before { opacity: 1; }

.kpi-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.kpi-icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-50), var(--brand-100));
  color: var(--brand-600);
  border: 1px solid var(--brand-100);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6),
              0 2px 4px -1px rgba(79,70,229,0.15);
  font-size: 16px;
}
.kpi-icon svg, .kpi-icon i { width: 18px; height: 18px; }
.kpi-icon.amber {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #b45309; border-color: #fde68a;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 4px -1px rgba(245,158,11,0.15);
}
.kpi-icon.teal {
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: #0f766e; border-color: #99f6e4;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 4px -1px rgba(20,184,166,0.15);
}
.kpi-icon.coral {
  background: linear-gradient(135deg, #ffe4e6, #fecdd3);
  color: #be123c; border-color: #fecdd3;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 4px -1px rgba(244,63,94,0.15);
}
.kpi-label {
  font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px;
}

/* ============================================================
   Chip / Badge
   ============================================================ */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600;
  background: var(--bg-subtle); color: var(--text-secondary);
  border: 1px solid var(--border-soft);
}
.chip.brand{background:var(--brand-50);color:var(--brand-700);border-color:var(--brand-100);}
.chip.success{background:#d1fae5;color:#047857;border-color:#a7f3d0;}
.chip.warn{background:#fef3c7;color:#b45309;border-color:#fde68a;}
.chip.danger{background:#fee2e2;color:#b91c1c;border-color:#fecaca;}
.chip.info{background:#dbeafe;color:#1e40af;border-color:#bfdbfe;}

/* ============================================================
   表单
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-ui); font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  transition: all .15s var(--ease-out);
  outline: none;
}
.form-input::placeholder { color: var(--text-placeholder); }
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: var(--border-strong); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px var(--brand-50);
}
.form-textarea { resize: vertical; min-height: 78px; font-family: var(--font-ui); }

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

.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ============================================================
   表格
   ============================================================ */
.table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-toolbar {
  padding: 14px 18px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-surface), var(--bg-subtle));
}
.table-toolbar .search {
  flex: 0 0 260px;
  padding: 7px 10px 7px 32px;
  background: var(--bg-surface) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%238a93a6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>') 10px center no-repeat;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm); font-size: 13px; outline: none;
}
.table-toolbar .search:focus { border-color: var(--brand-400); box-shadow: 0 0 0 3px var(--brand-50); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  text-align: left; padding: 11px 16px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-tertiary);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .td-mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }
.data-table .td-actions { white-space: nowrap; text-align: right; }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-surface);
  font-size: 12px; color: var(--text-tertiary);
}
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages button {
  min-width: 28px; height: 28px; padding: 0 8px;
  border: 1px solid var(--border-default); background: var(--bg-surface);
  border-radius: var(--r-sm); cursor: pointer; font-size: 12px;
  color: var(--text-secondary);
  transition: all .15s var(--ease-out);
}
.pagination .pages button:hover:not(:disabled) { border-color: var(--brand-300); color: var(--brand-600); }
.pagination .pages button.active {
  background: var(--brand-500); color: white; border-color: var(--brand-500);
}
.pagination .pages button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   Modal
   ============================================================ */
.modal-mask {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fade-in 0.2s var(--ease-out);
}
@keyframes fade-in { from {opacity:0} to {opacity:1} }
.modal {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  width: min(560px, 90vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  animation: modal-pop 0.3s var(--ease-spring);
}
.modal-lg { width: min(760px, 94vw); }
.modal-xl { width: min(960px, 96vw); }
@keyframes modal-pop {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border-soft);
}
.modal-head h3 { font-size: 17px; font-family: var(--font-display); }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--r-sm); border: none;
  background: transparent; cursor: pointer; color: var(--text-tertiary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
}
.modal-close:hover { background: var(--bg-subtle); color: var(--text-primary); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border-soft);
  display: flex; justify-content: flex-end; gap: 16px;
  background: var(--bg-subtle);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal-foot .btn + .btn { margin-left: 4px; }

/* ============================================================
   Toast
   ============================================================ */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  min-width: 260px; max-width: 400px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-primary);
  animation: toast-in 0.3s var(--ease-spring);
  pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warn { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }
.toast-icon { flex-shrink: 0; width: 18px; height: 18px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warn .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }
@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Empty state */
.empty {
  padding: 60px 20px; text-align: center; color: var(--text-tertiary);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }

/* Loading */
.loading-ring {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border-default);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loading {
  padding: 60px 20px; text-align: center; color: var(--text-tertiary);
}

/* Sparkline */
.sparkline { height: 36px; width: 100%; margin-top: 10px; }
