/* ============================================================
 * components.css —— 卡片 / 表格 / 按钮 / 表单 / 弹窗 / 图表 等组件
 * ============================================================ */

/* 配色 tone */
.tone-blue{color:#2563eb;background:#dbeafe}.tone-green{color:#16a34a;background:#dcfce7}
.tone-red{color:#dc2626;background:#fee2e2}.tone-amber{color:#d97706;background:#fef3c7}
.tone-purple{color:#7c3aed;background:#ede9fe}.tone-cyan{color:#0891b2;background:#cffafe}
.tone-teal{color:#0d9488;background:#ccfbf1}.tone-orange{color:#ea580c;background:#ffedd5}
.tone-indigo{color:#4f46e5;background:#e0e7ff}.tone-gray{color:#667085;background:#f2f4f7}

/* ---------------- 页面标题 ---------------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.page-subtitle { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------------- 面板 / 卡片 ---------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.panel-header h2 { font-size: 15px; font-weight: 650; }
.panel-header .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.panel-body { padding: 20px; }
.panel-body.tight { padding: 0; }
.panel-body.scroll { overflow-x: auto; }

/* ---------------- 统计卡片 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  transition: transform .16s, box-shadow .16s;
}
.stat-card[data-stat] { cursor: pointer; }
.stat-card[data-stat]:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16,24,40,.1); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 19px; height: 19px; }
.stat-value { font-size: 30px; font-weight: 750; margin-top: 12px; letter-spacing: -.5px; line-height: 1; }
.stat-value small { font-size: 13px; color: var(--text-3); font-weight: 500; margin-left: 3px; }
.stat-bottom { margin-top: 12px; display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.stat-trend { padding: 2px 7px; border-radius: 5px; font-weight: 600; }
.stat-trend.green { color: #16a34a; background: #dcfce7; }
.stat-trend.red { color: #dc2626; background: #fee2e2; }
.stat-hint { color: var(--text-3); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap;
  background: #fff; color: var(--text-2); border-color: var(--border);
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: #e5484d; color: #fff; border-color: #e5484d; }
.btn-danger:hover { background: #cf3338; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-icon-only { padding: 7px; width: 32px; height: 32px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon { display: inline-flex; }
.btn-icon svg, .btn > svg { width: 15px; height: 15px; flex-shrink: 0; }

/* 链接按钮（表格操作） */
.link-act {
  background: none; border: none; color: var(--primary);
  cursor: pointer; font-size: 12.5px; padding: 2px 5px; border-radius: 4px;
}
.link-act:hover { background: var(--primary-soft); }
.link-act.danger { color: #e5484d; }
.link-act.danger:hover { background: #fef2f2; }
.link-sep { color: #d0d5dd; margin: 0 2px; }

/* ---------------- 徽章 ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }

/* ---------------- 表格 ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 820px; }
.data-table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--text-2);
  background: #fafbfc; padding: 11px 16px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); color: var(--text-2); vertical-align: middle; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafcff; }
.data-table .clickable-row { cursor: pointer; }
.cell-strong { color: var(--text); font-weight: 600; }
.cell-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--text-3); font-size: 12px; }
.empty-cell { padding: 0 !important; }
.empty-state { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty-icon { font-size: 34px; opacity: .35; margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* ---------------- 筛选工具栏 ---------------- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 0 1 280px; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 18px; }
.search-input, .form-input, .form-select, .form-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; background: #fff; color: var(--text); outline: none; transition: .15s;
}
.search-input { padding-left: 32px; }
.search-input:focus, .form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-select { cursor: pointer; width: auto; min-width: 155px; flex: 0 0 auto; }
.filter-bar .form-select { min-width: 150px; }
.modal-form .form-select, .modal-form .form-input { width: 100%; }
.filter-spacer { flex: 1; }

/* ---------------- 弹窗 ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,24,40,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px; opacity: 0; transition: opacity .2s;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { opacity: 1; }
.modal {
  background: #fff; border-radius: 14px; width: 100%;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  max-height: calc(100vh - 40px); animation: modalIn .22s ease;
}
@keyframes modalIn { from { transform: translateY(12px) scale(.98); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 650; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-3); cursor: pointer; line-height: 1; width: 30px; height: 30px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 9px; flex-shrink: 0; }
.confirm-modal .modal-body p { color: var(--text-2); }

/* ---------------- 表单 ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.span-2 { grid-column: span 2; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.req { color: #e5484d; margin-left: 2px; }
.form-input, .form-select { height: 38px; padding: 7px 11px; }
.form-textarea { resize: vertical; line-height: 1.6; }
.form-hint { font-size: 11px; color: var(--text-3); }
.form-error { color: #e5484d; font-size: 12.5px; margin-top: 12px; min-height: 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; }
.kv-item { display: flex; flex-direction: column; gap: 3px; padding: 10px 0; border-bottom: 1px dashed var(--border-light); }
.kv-label { font-size: 11.5px; color: var(--text-3); }
.kv-value { font-size: 13.5px; color: var(--text); font-weight: 500; word-break: break-all; }

/* ---------------- 标签页 ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  background: none; border: none; padding: 9px 16px; cursor: pointer;
  font-size: 13px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); font-weight: 650; border-bottom-color: var(--primary); }

/* ---------------- 进度条 ---------------- */
.progress { height: 7px; background: #f0f2f5; border-radius: 4px; overflow: hidden; width: 100%; }
.progress-bar { height: 100%; border-radius: 4px; transition: width .3s; }

/* ---------------- 头像 ---------------- */
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }

/* ---------------- 时间线 ---------------- */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ''; position: absolute; left: -21px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2.5px solid var(--primary); }
.tl-action { font-weight: 650; font-size: 13.5px; }
.tl-meta { font-size: 11.5px; color: var(--text-3); margin: 2px 0 5px; }
.tl-note { font-size: 12.5px; color: var(--text-2); background: var(--bg); padding: 8px 11px; border-radius: 7px; }

/* ---------------- 图表 ---------------- */
.chart-box { width: 100%; overflow: hidden; }
.chart-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.donut-wrap { display: flex; align-items: center; justify-content: center; gap: 20px; flex-wrap: wrap; padding: 8px; }
.legend { display: flex; flex-direction: column; gap: 9px; min-width: 110px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.legend-item b { margin-left: auto; color: var(--text); }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }

/* ---------------- 轻提示 ---------------- */
#toast-box { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: #101828; color: #fff; padding: 10px 16px;
  border-radius: 9px; font-size: 13px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-8px); transition: .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast-icon { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; background: #12b76a; }
.toast-error .toast-icon { background: #e5484d; }
.toast-info .toast-icon { background: #2563eb; }

/* ---------------- 网格布局 ---------------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-row { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .stat-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-field.span-2 { grid-column: span 1; }
}
