/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
  overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-body { padding: 20px; }
.card-header {
  padding: 20px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table thead tr { background: #F8FAFC; }
.data-table th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}
.data-table th.th-left { text-align: left; }
.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid #F3F4F6;
  text-align: center;
}
.data-table td.td-left { text-align: left; }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: #F9FAFB; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tfoot tr { background: #F8FAFC; font-weight: 600; }
.data-table tfoot td { border-top: 2px solid var(--border); }

/* Compact numeric columns */
.data-table .col-num { width: 60px; padding-left: 6px; padding-right: 6px; }
.data-table.compact-num { table-layout: fixed; }
.data-table.compact-num .th-left { overflow: hidden; text-overflow: ellipsis; }

/* ===== Avatar ===== */
.avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.avatar-name { font-weight: 500; }

/* Avatar colors — varied */
.avatar-c0 { background: #3B82F6; }
.avatar-c1 { background: #8B5CF6; }
.avatar-c2 { background: #EC4899; }
.avatar-c3 { background: #10B981; }
.avatar-c4 { background: #F59E0B; }
.avatar-c5 { background: #06B6D4; }
.avatar-c6 { background: #EF4444; }
.avatar-c7 { background: #6366F1; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.badge-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
}
.badge-green { background: #ECFDF5; color: #059669; }
.badge-green .badge-dot { background: #059669; }
.badge-amber { background: #FFFBEB; color: #D97706; }
.badge-amber .badge-dot { background: #D97706; }
.badge-red { background: #FEF2F2; color: #DC2626; }
.badge-red .badge-dot { background: #DC2626; }
.badge-cyan { background: #EFF6FF; color: #2563EB; }
.badge-cyan .badge-dot { background: #3B82F6; }
.badge-purple { background: #F8FAFC; color: #64748B; }
.badge-purple .badge-dot { background: #64748B; }
.badge-slate { background: #F8FAFC; color: #64748B; }
.badge-slate .badge-dot { background: #64748B; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #2563EB; }
.btn-secondary { background: #F3F4F6; color: var(--text-secondary); }
.btn-secondary:hover { background: #E5E7EB; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 8px;
}
.btn-ghost:hover { background: #F3F4F6; }

/* ===== Form ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.form-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--blue); }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.select-input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  outline: none;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: #F3F4F6;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.modal-close:hover { background: #E5E7EB; }
.modal-body { padding: 20px 24px 24px; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}
.toast.success { background: #065F46; color: #fff; }
.toast.error { background: #991B1B; color: #fff; }
.toast.info { background: #1E40AF; color: #fff; }
@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Detail Modal Table ===== */
.detail-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.detail-table th {
  padding: 8px 12px;
  background: #F8FAFC;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.detail-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #F3F4F6;
  text-align: center;
}
.detail-table tfoot tr {
  background: #F8FAFC;
}
.detail-table tfoot td {
  border-top: 2px solid var(--border);
  padding: 10px 12px;
}
