/* ===== 组件样式 ===== */

/* 按钮 */
.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.danger-button {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 12px;
  font-weight: 700;
  transition: all var(--transition);
}

.primary-button {
  background: var(--teal);
  color: #fff;
}
.primary-button:hover { opacity: 0.9; }
.primary-button:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-button {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.secondary-button:hover { border-color: var(--teal); color: var(--teal); }

.ghost-button {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.ghost-button:hover { color: var(--ink); background: var(--surface-2); }

.danger-button {
  background: var(--rose);
  color: #fff;
}
.danger-button:hover { opacity: 0.9; }

.icon-button {
  width: 38px; padding: 0;
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

/* 表单输入 */
.global-search input,
.topbar select,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color var(--transition);
}

.global-search input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 120, 0.1);
}

.field input.invalid,
.field select.invalid {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(185, 65, 75, 0.1);
}

/* 卡片 */
.metric-card,
.record-card,
.role-card {
  display: grid;
  gap: 10px;
  min-height: 120px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: box-shadow var(--transition);
}

.metric-card:hover,
.record-card:hover { box-shadow: var(--shadow); }

.metric-card strong {
  font-size: 28px;
  line-height: 1;
}

.metric-card span,
.record-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card small {
  color: var(--green);
  font-weight: 700;
}

.record-card { min-height: auto; }
.role-card { min-height: auto; }

.record-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.record-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.card-actions .secondary-button,
.card-actions .danger-button {
  font-size: 12px;
  min-height: 30px;
  padding: 4px 12px;
}

.mini-metrics {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.mini-metrics b {
  color: var(--text);
  font-size: 16px;
}

/* 标签 */
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.pill.ok { background: #e8f4e9; color: var(--green); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.danger { background: var(--rose-soft); color: var(--rose); }

/* 表格 */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcf9; }

tr.group-header td {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

tr.group-header:hover { background: var(--surface-2); }

.row-title {
  display: grid;
  gap: 4px;
}

.row-title strong { color: var(--ink); }
.row-title span { color: var(--muted); font-size: 12px; }

.progress-cell {
  display: grid;
  gap: 6px;
  width: 160px;
}

.progress-track,
.bar-track {
  position: relative;
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e7ece6;
}

.progress-track i,
.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 0.4s ease;
}

.bar-list { display: grid; gap: 14px; }

.bar-row {
  display: grid;
  grid-template-columns: 128px minmax(100px, 1fr) 58px;
  gap: 10px;
  align-items: center;
}

.bar-row span,
.bar-row b { font-size: 13px; }
.bar-row b { text-align: right; }

/* 详情面板 */
.detail-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.detail-panel h3 { margin: 0; font-size: 18px; }

.detail-list { display: grid; gap: 10px; }

.detail-item {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  font-size: 13px;
}

.detail-item span:first-child { color: var(--muted); }

.record-list { display: grid; gap: 10px; }

/* 权限表 */
.permission-table th:first-child,
.permission-table td:first-child {
  position: sticky;
  left: 0; z-index: 2;
  background: var(--surface-2);
}

.checkbox-cell { text-align: center; }
.checkbox-cell input { width: 18px; height: 18px; }

/* 时间线 */
.timeline { display: grid; gap: 12px; }

.timeline-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child { border-bottom: 0; }
.timeline-item time { color: var(--muted); font-size: 13px; }
.timeline-item strong { display: block; margin-bottom: 4px; }

/* 分区 */
.section-band {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h3 { margin: 0; font-size: 18px; }

.empty-state {
  padding: 34px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  text-align: center;
}

/* 角色网格 */
.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
